【问题标题】:Cordova app restart after getting picture from capture or photo Librairie从捕获或照片库中获取图片后 Cordova 应用程序重新启动
【发布时间】:2014-12-07 20:19:35
【问题描述】:

我正在尝试在我的服务器上使用 jquery mobile 和 php 在适用于 android 的 cordova 项目上添加图片。

当我从我的图书馆中选择一张图片或进行拍摄时,应用程序会重新启动,而不是用图片刷新我的表单。

这是我的 html 代码:

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

这是我的 jquery 移动代码:

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

我到处搜索,但找不到任何解决方案。

编辑,我有最新版本的 cordova 和最后一个文件插件

【问题讨论】:

    标签: html jquery-mobile cordova


    【解决方案1】:

    幸运的是,我已经尝试更改 html 代码,以防万一,这里是解决方案:

    我只是更改了这段代码:

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

    到这里:

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

    不要使用 html 按钮标签,使用锚标签...不知道为什么,但这有效!!!

    【讨论】:

    • 直到两天我才能接受自己的答案,奇怪:(
    猜你喜欢
    • 2020-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多