本文介绍了如何在ibm worklight中打开本机相机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Ibm Worklight具有调用本机应用程序的样本,但是它在worklight本身中创建,例如:本示例中的module_09_1_Android_CombiningNativeAndWebPages在android文件夹中,它们创建一个活动com.AndroidShowNativePage.HelloNative(包名称)那个javascript。

Ibm Worklight have samples that calling the native app, but that was created in worklight itself eg: module_09_1_Android_CombiningNativeAndWebPages in this sample in android folder itself they creating one activity "com.AndroidShowNativePage.HelloNative" (package name) that activity was invoking from that javascript.

但是,我需要从工作台调用本机相机 com.android.camera 是可能吗?如果是,请分享您的知识。

But, i need to call the native camera "com.android.camera" from the worklight is that possible ? if yes, please share your knowledge. Thanks in Advance!!

推荐答案

在您的应用程序中使用此函数。默认情况下,Cordova插件安装在worklight应用程序中。你需要调用它的功能

Use this function in your applicaton. By default Cordova plugin is installed in worklight application. you need to just call its functionality

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});
};

这篇关于如何在ibm worklight中打开本机相机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 17:27