[編集]
私は実際にこれを解決し、次の行をアクティビティ マニフェストに追加しました。
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>