Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2125] Open Photo Gallery and Show Camera Methods are not working on Android 4.0.4 version with Titanium Studio 3.1

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionFixed
Resolution Date2013-11-22T22:21:48.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
ReporterAnuja Dharmadhikari
AssigneeMauro Parra-Miranda
Created2013-11-12T04:37:57.000+0000
Updated2016-03-08T07:41:06.000+0000

Description

Methods for opening Photo gallery (openPhotoGallery) and Show Camera methods are not working on android 4.0.4 version

Comments

  1. Mostafizur Rahman 2013-11-21

    Hello, We have tested this issue with the test code below. It’s working fine for us. Please try out this code to see if you can reproduce it. If you continue to encounter this issue, please send us your test sample. Regards,

    Test Environment:

    OS: MAC OS X 10.8.5 Ti SDK: 3.1.3 GA Ti CLI: 3.2.0 Android SDK 4.2.2 Device Android SDK 4.0.3 in Emulator

    My test code

        var win = Ti.UI.createWindow();
       
       var contenner = Ti.UI.createView({
       	width : Ti.UI.FILL,
       	height : Ti.UI.SIZE,
       	top : 0,
       	backgroundColor : '#eee',
       	borderColor : '#eee',
       	layout : 'vertical',
       });
       win.add(contenner);
       
        var anImageView = Ti.UI.createImageView({ 
       	width : 'auto',
       	height : 'auto',
       	top : 20,
       });
       contenner.add(anImageView);
       
        
       
       var frmcamera = Ti.UI.createButton({
       	backgroundImage : 'none',
       	backgroundColor : '#ff0000',
       	title : 'Open Camera',
       	color : '#fff',
       	width : Ti.UI.SIZE,
       	height : 50,
       	font : {
       		fontSize : 14, 
       	},
       	left : 10,
       });
       
       frmcamera.addEventListener('click', function() {
       	fireUpTheCamera();
       });
       
       contenner.add(frmcamera);
       
       var frmgalary = Ti.UI.createButton({
       	backgroundImage : 'none',
       	backgroundColor : '#ff0000',
       	title : 'Open Gallery',
       	color : '#fff',
       	width : Ti.UI.SIZE,
       	height : 50,
       	font : {
       		fontSize : 14, 
       	},
       	right : 10,
       });
       
       frmgalary.addEventListener('click', function() {
       	Ti.Media.openPhotoGallery({
       		mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO],
       		success : function(e) {
       			anImageView.image = e.media;
       
       		},
       		cancel : function() {
       		},
       		error : function(err) {
       		}
       	});
       });
       
       contenner.add(frmgalary);
       
       function fireUpTheCamera() {
       	Titanium.Media.showCamera({
       
       		success : function(event) {
       			var cropRect = event.cropRect;
       			var image = event.media;
       
       			Ti.API.debug('Our type was: ' + event.mediaType);
       			if (event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO) {
       				anImageView.image = image;
       
       			} else {
       				alert("got the wrong type back =" + event.mediaType);
       			}
       		},
       		cancel : function() {
       		},
       		error : function(error) {
       			// create alert
       			var a = Titanium.UI.createAlertDialog({
       				title : 'Camera'
       			});
       
       			// set message
       			if (error.code == Titanium.Media.NO_CAMERA) {
       				a.setMessage('Please run this test on device');
       			} else {
       				a.setMessage('Unexpected error: ' + error.code);
       			}
       
       			// show alert
       			a.show();
       		},
       		saveToPhotoGallery : true,
       		allowEditing : true,
       		mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO]
       	});
       }
       
       win.open();
       
       

    Step to test

    1. Create a new project 2. Paste test code in app.js 3. Now run on android device/Emulator 4. Click on Open Gallery/ Open Camera button 5. Select photo from gallery or take photo from camera h5. Expect Result/Actual Result Working as expected.
  2. Mauro Parra-Miranda 2013-11-22

    Working fine with 3.1.3
  3. Nuno Costa 2013-11-23

    Not work with titanium_mobile 3.2.0.v20131122125648, at least "Show Camera". Tested in real android device 4.2.1 and Genymotion 2.1 with android 4.3
  4. Nuno Costa 2013-11-23

    I confirm that working fine with 3.1.3.GA

JSON Source