IBM工作灯有调用本机应用程序的样本,但在工作灯本身如创建:module_09_1_Android_CombiningNativeAndWebPages此示例中的Android文件夹本身,他们创造一个活动“com.AndroidShowNativePage.HelloNative”(包名)的活动范围也从JavaScript的调用英寸
但是,我需要从工作灯调用本机相机“com.android.camera”这可能吗? 如果是,请分享你的知识。 提前致谢!!
IBM工作灯有调用本机应用程序的样本,但在工作灯本身如创建:module_09_1_Android_CombiningNativeAndWebPages此示例中的Android文件夹本身,他们创造一个活动“com.AndroidShowNativePage.HelloNative”(包名)的活动范围也从JavaScript的调用英寸
但是,我需要从工作灯调用本机相机“com.android.camera”这可能吗? 如果是,请分享你的知识。 提前致谢!!
在一个应用使用此功能。 默认情况下,科尔多瓦插件安装在工作灯的应用程序。 你只是需要调用它的功能
function takePicture() {
navigator.camera.getPicture(
function(data) {
var img = dom.byId('camera_image');
img.style.visibility = "visible";
img.style.display = "block";
//img.src = "data:image/jpeg;base64," + data;
img.src = data;
dom.byId('camera_status').innerHTML = "Success";
},
function(e) {
console.log("Error getting picture: " + e);
dom.byId('camera_status').innerHTML = e;
dom.byId('camera_image').style.display = "none";
},
{ quality: 50, destinationType: navigator.camera.DestinationType.FILE_URI, sourceType : navigator.camera.PictureSourceType.CAMERA});
};
Why write code that will work on Android and not on iPhone? Worklight uses PhoneGap, so you can use camera.getPicture and get to your application the image taken with the camera as base64.
navigator.camera.getPicture( cameraSuccess, cameraError, [ cameraOptions ] );
See PhoneGap documentation for more information (http://docs.phonegap.com/en/1.0.0/phonegap_camera_camera.md.html).