Cordova app restart after getting picture from capture or photo Librairie

喜夏-厌秋 提交于 2020-01-22 02:15:32

问题


i'm trying to add picture on my server with jquery mobile and php on a cordova project for android.

When i select a picture from my librairie or i make a capture, the app restart instead of refreshing my form with the picture.

here is my html code:

<button onclick="capturePhoto();">Capture Photo</button>
<button onclick="getPhoto(pictureSource.PHOTOLIBRARY);">From Photo Library</button>

here is my jquery mobile code:

function capturePhoto() {
    navigator.camera.getPicture(onPhotoDataSuccess, onFail, {
        quality: 50,
        targetWidth: 600,
        targetHeight: 600,
        destinationType: destinationType.FILE_URI,
        encodingType:navigator.camera.EncodingType.JPEG,
        saveToPhotoAlbum: true
    });
}

function getPhoto(source) {
    navigator.camera.getPicture(onPhotoURISuccess, onFail, {
        quality: 50,
        targetWidth: 600,
        targetHeight: 600,
        destinationType: destinationType.FILE_URI,
        encodingType:navigator.camera.EncodingType.JPEG,
        sourceType: source
    });
}

I've searched everywhere but i can't find any solution.

EDIT, i have the last version of cordova and the last of file plugin


回答1:


By luck, i've tried to change the html code, just in case, and here is the solution:

I just change this code:

<button onclick="capturePhoto();">Capture Photo</button>

to this:

<a href="" class="ui-btn" onclick="capturePhoto();">Capture Photo</a>

Don't use html buttons tag, use anchor tag... don't know why but this worked !!!



来源:https://stackoverflow.com/questions/27342468/cordova-app-restart-after-getting-picture-from-capture-or-photo-librairie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!