Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15812] Android: Media: Camera is not opening with overlay property set in Ti.Media.showCamera()

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2015-01-07T00:12:03.000+0000
Affected Version/sRelease 3.2.0
Fix Version/sRelease 4.0.0
ComponentsAndroid
Labelsqe-3.2.0
ReporterParas Mishra
AssigneeAshraf Abu
Created2013-11-25T12:40:07.000+0000
Updated2015-02-12T03:00:00.000+0000

Description

Android: Media: Camera is not opening with overlay property set in Ti.Media.showCamera(). It also occur on SDK: 3.1.3.GA Steps to reproduce 1. Run the below app.
var _window = Ti.UI.createWindow({
	backgroundColor:'white'
}); 
	var openCameraButton = Ti.UI.createButton({
		title : 'Open Camera'
	});

	openCameraButton.addEventListener('click', function(e) {
		var cameraOverlay = Ti.UI.createView();

		var takePhotoButton = Ti.UI.createButton({
			backgroundColor : '#fff',
			backgroundSelectedColor : '#efefef',
			borderColor : '#000',
			borderRadius : 17,
			borderWidth : 1,
			bottom : 65,
			color : '#000',
			height : 34,
			opacity : 0.4,
			title : 'Take Photo',
			width : '100dp'
		});

		var closeCameraButton = Ti.UI.createButton({
			backgroundColor : '#fff',
			backgroundSelectedColor : '#efefef',
			borderColor : '#000',
			borderRadius : 17,
			borderWidth : 1,
			bottom : 65,
			color : '#000',
			height : 34,
			opacity : 0.4,
			right : 10,
			title : 'Close Camera',
			top : 10,
			width : '150dp'
		});

		takePhotoButton.addEventListener('click', function(e) {
			Ti.Media.takePicture();
		});

		closeCameraButton.addEventListener('click', function(e) {
			alert('closing camera');
			Ti.Media.hideCamera();
		});

		cameraOverlay.add(takePhotoButton);
		cameraOverlay.add(closeCameraButton);

		Ti.Media.showCamera({
			success : function(e) {
				alert('success callback');
			},
			cancel : function() {
				Ti.API.info('cancel callback');
			},
			error : function(e) {
				Ti.API.info('error callback');
			},
			allowEditing : false,
			animated : false,
			autohide : false,
			mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO],
			overlay : cameraOverlay,
			saveToPhotoGallery : false,
			showControls : false
		});
	});

	_window.add(openCameraButton);

_window.open();

if overlay property is commented then the app works fine. Expected: Camera is opened. Actual: Camera does not open.

Comments

  1. Sunila 2013-12-01

    Is this specific to device or Android version? It is working in my Galaxy Nexus running Android 4.3
  2. Biju pm 2013-12-02

    The issue cannot reproduce with the release master 3.2.0 Tested with: Titanium Studio, build: 2.1.2.201208301612 Titanium SDK version: 3.2.0 Tested on Device: Samsung galaxy s duos Android version: 4.0.4
  3. Neha Mittal 2014-01-21

    Issue still reproducible on following environment: Appcelerator Studio, build: 3.2.1.201401151647 SDK build: 3.2.1.v20140117222448 acs@1.0.11 alloy@1.3.1-beta2 npm@1.3.2 titanium@3.2.1 titanium-code-processor@1.1.0 Mac9(Maverick) Devices: Nexus 7(4.3) Camera is not opening with overlay property while this is working fine on iOS.
  4. Ashraf Abu 2015-01-06

    Issue was for devices like Nexus 7 (2012), code was trying to use rear facing camera which doesn't exists when overlay is being used. PR: https://github.com/appcelerator/titanium_mobile/pull/6536
       var _window = Ti.UI.createWindow({
       	backgroundColor:'white'
       }); 
       	var openCameraButton = Ti.UI.createButton({
       		title : 'Open Camera'
       	});
       
       	openCameraButton.addEventListener('click', function(e) {
       		var cameraOverlay = Ti.UI.createView();
       
       		var takePhotoButton = Ti.UI.createButton({
       			backgroundColor : '#fff',
       			backgroundSelectedColor : '#efefef',
       			borderColor : '#000',
       			borderRadius : 17,
       			borderWidth : 1,
       			bottom : 65,
       			color : '#000',
       			height : 34,
       			opacity : 0.4,
       			title : 'Take Photo',
       			width : '100dp'
       		});
       
       		var closeCameraButton = Ti.UI.createButton({
       			backgroundColor : '#fff',
       			backgroundSelectedColor : '#efefef',
       			borderColor : '#000',
       			borderRadius : 17,
       			borderWidth : 1,
       			bottom : 65,
       			color : '#000',
       			height : 34,
       			opacity : 0.4,
       			right : 10,
       			title : 'Close Camera',
       			top : 10,
       			width : '150dp'
       		});
       
       		takePhotoButton.addEventListener('click', function(e) {
       			Ti.Media.takePicture();
       		});
       
       		closeCameraButton.addEventListener('click', function(e) {
       			alert('closing camera');
       			Ti.Media.hideCamera();
       		});
       
       		cameraOverlay.add(takePhotoButton);
       		cameraOverlay.add(closeCameraButton);
       
       		Ti.Media.showCamera({
       			success : function(e) {
       				alert('success callback');
       			},
       			cancel : function() {
       				Ti.API.info('cancel callback');
       			},
       			error : function(e) {
       				Ti.API.info('error callback');
       			},
       			allowEditing : false,
       			animated : false,
       			autohide : false,
       			mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO],
       			overlay : cameraOverlay,
       			saveToPhotoGallery : false,
       			showControls : false
       		});
       	});
       
       	_window.add(openCameraButton);
       
       _window.open();
       
  5. Ewan Harris 2015-02-12

    Verified fix on: Mac OSX 10.10.2 Appcelerator Studio, build: 4.0.0.201502051633 Titanium SDK build: 4.0.0.v20150211081857 Titanium CLI, build: 3.6.0-dev Alloy: 1.5.1 Android build tools 21.1.1 Nexus 7 (4.3) Built to device, the camera now opens and uses the front camera. Closing ticket.

JSON Source