PhoneGap的 - 机器人 - 如何从相机保存捕获图像中的SD卡机器人、图像、相机、PhoneGap

2023-09-06 06:36:58 作者:冷暖自知

我是新的PhoneGap的Andr​​oid开发者。我正在使用的PhoneGap在Android的应用程序。我想拍照的设备摄像头,然后我想,从设备和以及存储在SD卡中拍摄的图像拍摄后的图像在屏幕上显示。你能告诉我怎样才能做到这一点。

I'm new in PhoneGap Android developer. I'm making an application in android using the phonegap. I want to take picture from the device camera and then i want to display it on the screen after taking the image from device and as well as store that captured image in the SD Card. Can you please tell me how i can do this.

古尔$ P $宠物辛格

Gurpreet singh

推荐答案

有关节能的SD卡......

For saving in the SD card......

function save(){

    document.addEventListener("deviceready", onDeviceReady, false);
}



    // PhoneGap is ready
    //
    function onDeviceReady() {
        window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
    }

    function gotFS(fileSystem) {
        fileSystem.root.getFile("pic.jpg", {create: true, exclusive: false}, gotFileEntry, fail);
    }

    function gotFileEntry(fileEntry) {
        fileEntry.createWriter(gotFileWriter, fail);
    }

    function gotFileWriter(writer) {

        var photo = document.getElementById("image");
        writer.write(photo.value);

    }

    function fail(error) {
        console.log(error.code);
    }