Reputation: 4691
I am developing an application for Android using PhoneGap (Cordova 1.6.1). My application crashes when I invoke the camera API and I am getting log messages like "showStatusIcon on inactive InputConnection". I have used the following methods to invoke the camera:
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);
}
Upvotes: 2
Views: 889
Reputation: 1
In the onCreate method of my activity class I have set a Javascript interface:
appView.addJavascriptInterface(this, "GC");
And I have created a method for cleaning the garbage collector:
public void cleanGC() {
System.gc();
}
In my .js file, I call the previous method before to call the camera or the picture gallery:
GC.cleanGC();
Upvotes: 0
Reputation: 2983
I have used it like this and it is working fine for me. Please check -
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>
Upvotes: 1