保存使用相机和旋转手机拍摄的图像时,Android应用程序会死机

时间:2012-09-18 16:59:04

标签: javascript android cordova jquery-mobile android-camera

[编辑]

我实际上解决了这个问题,将以下行添加到我的活动清单中:

android:configChanges="orientation|keyboardHidden"

我正在尝试使用phonegap保存使用我的Android手机拍摄的图像,但是80%的时间我按下保存按钮,拍完照片后,我的应用程序就死了......

我已经看到这是phonegap + android的常见问题。我已经尝试降低图像质量,清理手机内存,删除应用程序的缓存目录......到目前为止,我还没有得到这种随机行为。

我尝试过使用imageData和imageURI,但仍然会收到错误。

需要注意的是,每次旋转手机时,我的应用都会消失。有时,当我保存图像时,屏幕会自动旋转,同时也会杀死应用程序。

这是我到目前为止的代码......

            // Called when a photo is successfully retrieved
            //
            function onPhotoURISuccess(imageURI) {
                // Uncomment to view the image file URI
                // console.log(imageURI);

                $('#my_div') // this div belongs to my html markup (see bellow)
                    .empty()
                    .append(
                        $('<image>')
                            .attr('src', imageURI)
                            .attr('width', '100')
                            .attr('height', '100')
                            .css({
                                'background-color' : 'red',
                                 '-webkit-border-radius': '15px',
                                 '-moz-border-radius': '15px',
                                 'border-radius': '15px'
                            })
                );
            }

            // A button will call this function
            //
            function getPhoto(source) {
                // Retrieve image file location from specified source
                navigator.camera.getPicture(
                    function (imageUri) {
                        onPhotoURISuccess(imageUri, photo_div_id);   
                    }, 
                    onFail, {
                        quality: 30,
                        destinationType: Camera.DestinationType.FILE_URI,
                        sourceType: source
                    }
                );
            }

<div   id="my_div" class= "iconP">
   <input type="button"  name="photo_1" id="photo_1" onclick ="getPhoto()" value="photo 1"/>
</div>

0 个答案:

没有答案
相关问题