我正在使用PhoneGap(Cordova 1.6.1)开发Android应用程序。当我调用相机API时,我的应用程序崩溃了,并且我收到了诸如“showStatusIcon on inactive InputConnection”之类的日志消息。我使用以下方法来调用相机:
function capturePhoto() {
// Take picture using device camera and retrieve image as base64-encoded string
navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50,
destinationType: destinationType.DATA_URL });
}
function onPhotoDataSuccess(imageData) {
var smallImage = document.getElementById('smallImage');
smallImage.style.display = 'block';
smallImage.src = "data:image/jpeg;base64," + imageData;
}
function onFail(message) {
alert('Failed because: ' + message);
}
答案 0 :(得分:1)
我已经像这样使用它,它对我来说很好。请检查 -
document.addEventListener("deviceready",onDeviceReady,false);
function onDeviceReady() {
console.log("CORDOVA IS WORKING:::");
}
function capturePhoto()
{
navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
destinationType: Camera.DestinationType.FILE_URI });
}
function onSuccess(imageURI) {
var image = document.getElementById('myImage');
image.src = imageURI;
}
function onFail(message) {
alert('Failed because: ' + message);
}
</script>
答案 1 :(得分:0)
在我的activity类的onCreate方法中,我设置了一个Javascript接口:
appView.addJavascriptInterface(this, "GC");
我已经创建了一种清理垃圾收集器的方法:
public void cleanGC() {
System.gc();
}
在我的.js文件中,我之前调用上一个方法来调用相机或图片库:
GC.cleanGC();