Project: titanium
Issue TIMOB-19654: Android: Error accessing Camera on device below M
Running code: {code} 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'});	a.setMessage(JSON.stringify(error));	a.show();	},	saveToPhotoGallery:true }); {code} Gives rise to log error: {code} 10-01 13:07:22.718: E/TiExceptionHandler(27510): (main) [51,51] ----- Titanium Javascript Runtime Error ----- 10-01 13:07:22.718: E/TiExceptionHandler(27510): (main) [0,51] - In app.js:1,16 10-01 13:07:22.718: E/TiExceptionHandler(27510): (main) [1,52] - Message: Uncaught Error: android.app.Activity.checkSelfPermission 10-01 13:07:22.718: E/TiExceptionHandler(27510): (main) [0,52] - Source: Titanium.Media.showCamera({ {code} Due to https://github.com/appcelerator/titanium_mobile/blob/32600b01047b4654c92b341c6f0b61d38fa702b1/android/modules/media/src/java/ti/modules/titanium/media/MediaModule.java#L288 http://developer.android.com/reference/android/content/Context.html#checkSelfPermission(java.lang.String) Being only available in API Level 23 and above. More logs: {code} 10-01 13:07:22.628: W/System.err(27510): java.lang.NoSuchMethodError: android.app.Activity.checkSelfPermission 10-01 13:07:22.628: W/System.err(27510): ti.modules.titanium.media.MediaModule.hasPermissions(MediaModule.java:288) 10-01 13:07:22.628: W/System.err(27510): ti.modules.titanium.media.MediaModule.showCamera(MediaModule.java:300) 10-01 13:07:22.628: W/System.err(27510): org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method) 10-01 13:07:22.628: W/System.err(27510): org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(V8Runtime.java:177) 10-01 13:07:22.628: W/System.err(27510): org.appcelerator.kroll.KrollRuntime.handleMessage(KrollRuntime.java:299) 10-01 13:07:22.628: W/System.err(27510): org.appcelerator.kroll.runtime.v8.V8Runtime.handleMessage(V8Runtime.java:203) 10-01 13:07:22.628: W/System.err(27510): android.os.Handler.dispatchMessage(Handler.java:98) 10-01 13:07:22.628: W/System.err(27510): android.os.Looper.loop(Looper.java:136) 10-01 13:07:22.628: W/System.err(27510): org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112) {code}
Story points: 3