Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6351] Android: saveToPhotoGallery:false does not work in android.

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionCannot Reproduce
Resolution Date2012-09-13T20:05:22.000+0000
Affected Version/sRelease 1.8.0.1
Fix Version/sn/a
ComponentsAndroid
LabelsSupportTeam, api
ReporterFrancisco Antonio Duran Ramirez
AssigneeShak Hossain
Created2011-11-29T09:59:57.000+0000
Updated2013-09-27T02:36:42.000+0000

Description

Problem

SaveToPhotoGallery:false does not work in android.

Reproducible steps:

1. Run the code below

Expected behavior:

Customer does not want to save the image to the gallery after taking a picture.

More info:

In iOS works well. http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Media.showCamera-method.html saveToPhotoGalleryboolean if the media should be saved to the photo gallery upon successful capture.

Tested with the next specs:

Samsung Galaxy Fit-Android Version : 2.2.1 iPhone 3G Version: 4.3.5 Simulator Titanium Studio, build: 1.0.7.201111231202 Titanium SDK: 1.8.0.v20111114103905 Google APIs Android 2.3.3

Sample code:

var mwin = Ti.UI.createWindow({
	backgroundColor : 'orange'
});

var btnShowCamera = Ti.UI.createButton({
	title : 'Take picture',
	width : 150,
	height : 70,
	top : 50
});

mwin.add(btnShowCamera);

btnShowCamera.addEventListener('click', function(e) 
{
	var win = Titanium.UI.currentWindow;
	Titanium.Media.showCamera(
	{
		mediaTypes : Titanium.Media.MEDIA_TYPE_PHOTO,
		allowEditing : true,
		saveToPhotoGallery:true,

		success : function(event) 
		{
			var cropRect = event.cropRect;
			var image = event.media;
			
			var imageView = Titanium.UI.createImageView(
			{
				image : image,
				width : 480,
				height : 640
			});
			
			image = imageView.toBlob();
			var photoPath = '';
			var photoDir = '';

			if(Titanium.Filesystem.isExternalStoragePresent()) 
			{
				photoDir = Titanium.Filesystem.getFile(Titanium.Filesystem.externalStorageDirectory, 'PlayGroundPhotos');
				if(!photoDir.exists()) 
				{
					photoDir.createDirectory();
				}
			}
			photoPath = photoDir.nativePath;
			var f = Titanium.Filesystem.getFile(photoPath, 'tony.jpg');
			f.write(image);
		},
	
		cancel : function() 
		{
		},
	});
});
mwin.open();

Helpdesk

APP-344567

Comments

  1. Devang Gandhi 2012-03-30

    I also reproduced the similar behavior: when saveToPhotoGallery=false, picture is saved in Camera folder, as well as folder named sample code:
       var win = Ti.UI.createWindow();
       
       
       
       Titanium.Media.showCamera({
           success:function(event) {
               // called when media returned from the camera
               Ti.API.debug('Our type was: '+event.mediaType);
               if(event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO) {
                   var imageView = Ti.UI.createImageView({
                       width:win.width,
                       height:win.height,
                       image:event.media
                   });
                   win.add(imageView);
               } else {
                   alert("got the wrong type back ="+event.mediaType);
               }
           },
           cancel:function() {
               // called when user cancels taking a picture
           },
           error:function(error) {
               // called when there's an error
               var a = Titanium.UI.createAlertDialog({title:'Camera'});
               if (error.code == Titanium.Media.NO_CAMERA) {
                   a.setMessage('Please run this test on device');
               } else {
                   a.setMessage('Unexpected error: ' + error.code);
               }
               a.show();
           },
           saveToPhotoGallery:false,
           allowEditing:true,
           mediaTypes:[Ti.Media.MEDIA_TYPE_VIDEO,Ti.Media.MEDIA_TYPE_PHOTO]
       });
       
       win.open();
       
       
  2. Vinothbabu 2012-06-22

    Is there any update on this issue, we are facing it in 2.0.2 as well. When placing saveToPhotoGallery:false, it does get saved in the DCIM/Camera/My_APP
  3. Neeraj Gupta 2012-06-22

    @Vinothbabu - We are not able to reproduce this issue with the latest master build (2.1.0). Please try your application with the latest build and see if it resolves the issue.
  4. Betty Tran 2012-08-28

    The issue is still occurring, I was able to reproduce using 2.1.1GA and the latest master build (2.2.0).
  5. Karl Rowley 2012-08-30

    What is the criteria being used to determine if a picture gets saved to the gallery here? I wouldn't expect that criteria to be whether the photo shows up in the Android Gallery app -- that app can find photos anywhere in phone storage in Android 4.0. The Appcelerator docs says this about saveToPhotoGallery: saveToPhotoGallery : Boolean Specifies if the media should be saved to the photo gallery upon successful capture. Defaults to: False I tried the code above, these are the results on Samsung Galaxy S3 (Sprint) running Android 4.0: (1) saveToPhotoGallery=true Image is saved to /mnt/sdcard/Pictures//.jpg This is the standard Android location to store pictures, with a sub-folder named for the app. (2) saveToPhotoGallery=false Image is saved to /mnt/extSdCard/DCIM/Camera/.jpg This is the location on my phone where I have configured the Android Camera app to store images (note that I've configured the camera app to put images on the SD card with is /mnt/extSdCard in this case).
  6. Karl Rowley 2012-08-30

    I think the customer is asking to not save an extra copy of a photo -- it doesn't look like the saveToPhotoGallery option was intended to do that. I talked to Josh, and he pointed out that some camera apps from various manufacturers don't give the user an option not to do this. An alternative is to use an overlay as described here to avoid using the in-device camera app: http://docs.appcelerator.com/titanium/2.1/index.html#!/api/CameraOptionsType
  7. Neeraj Gupta 2012-09-13

    Resolving this ticket in the correct status as we were not able to reproduce the issue reported in this ticket.
  8. Ygor Lemos 2013-09-12

    This is still happening on Ti SDK 3.1.2.GA Tested on several devices (Android 4.0, 4.1, 4.2 and 4.3) Devices: Nexus 7 (2013), Samsung Galaxy S2, Samsung Galaxy S3, Samsung Galaxy S4, LG L5, Motorola Razr PhoneGap solved this as per: http://simonmacdonald.blogspot.ca/2012/07/change-to-camera-code-in-phonegap-190.html
  9. Ygor Lemos 2013-09-27

    any news on this one?

JSON Source