我目前正在寻找简单地拍摄照片,并在相机关闭后立即将图片添加为 HTML 图像的源。但我不断收到以下错误:
09-09 19:16:07.764: E/System(10719): Uncaught exception thrown by finalizer
09-09 19:16:07.780: D/dalvikvm(10719): GC_CONCURRENT freed <1K, 10% free 19133K/21127K, paused 1ms+2ms
09-09 19:16:07.788: E/System(10719): java.lang.IllegalStateException: Binder has been finalized!
09-09 19:16:07.788: E/System(10719): at android.os.BinderProxy.transact(Native Method)
09-09 19:16:07.788: E/System(10719): at android.database.BulkCursorProxy.close(BulkCursorNative.java:288)
09-09 19:16:07.788: E/System(10719): at android.database.BulkCursorToCursorAdaptor.close(BulkCursorToCursorAdaptor.java:133)
09-09 19:16:07.788: E/System(10719): at android.database.CursorWrapper.close(CursorWrapper.java:49)
09-09 19:16:07.788: E/System(10719): at android.content.ContentResolver$CursorWrapperInner.close(ContentResolver.java:1591)
09-09 19:16:07.788: E/System(10719): at android.content.ContentResolver$CursorWrapperInner.finalize(ContentResolver.java:1604)
09-09 19:16:07.788: E/System(10719): at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:182)
09-09 19:16:07.788: E/System(10719): at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:168)
09-09 19:16:07.788: E/System(10719): at java.lang.Thread.run(Thread.java:856)
09-09 19:16:08.585: D/dalvikvm(10719): GC_EXPLICIT freed 12354K, 68% free 6804K/21127K, paused 2ms+3ms
09-09 19:16:08.585: E/System(10719): Uncaught exception thrown by finalizer
09-09 19:16:08.585: E/System(10719): java.lang.IllegalStateException: Binder has been finalized!
09-09 19:16:08.585: E/System(10719): at android.os.BinderProxy.transact(Native Method)
09-09 19:16:08.585: E/System(10719): at android.database.BulkCursorProxy.close(BulkCursorNative.java:288)
09-09 19:16:08.585: E/System(10719): at android.database.BulkCursorToCursorAdaptor.close(BulkCursorToCursorAdaptor.java:133)
09-09 19:16:08.585: E/System(10719): at android.database.CursorWrapper.close(CursorWrapper.java:49)
09-09 19:16:08.585: E/System(10719): at android.content.ContentResolver$CursorWrapperInner.close(ContentResolver.java:1591)
09-09 19:16:08.585: E/System(10719): at android.content.ContentResolver$CursorWrapperInner.finalize(ContentResolver.java:1604)
09-09 19:16:08.585: E/System(10719): at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:182)
09-09 19:16:08.585: E/System(10719): at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:168)
09-09 19:16:08.585: E/System(10719): at java.lang.Thread.run(Thread.java:856)
09-09 19:16:08.585: D/DroidGap(10719): Resuming the App
现在我使用的是 Android 4.0.3 和 Cordova 2.3.0。我目前有以下代码:
HTML
<button onclick="capturePhoto();">Take Photo</button>
<img id="cameraPic" src="" style="width:auto;height:120px;"></img>
JavaScript
var pictureSource;
var destinationType;
function onDeviceReady() {
pictureSource=navigator.camera.PictureSourceType;
destinationType=navigator.camera.DestinationType;
}
function capturePhoto(){
navigator.camera.getPicture(uploadPhoto,null,{ quality: 20, allowEdit: true,
destinationType: destinationType.DATA_URL });
};
function uploadPhoto(data){
// this is where you would send the image file to server
//output image to screen
$("#cameraPic").src = "data:image/jpeg;base64," + data;
}
我真的不确定为什么会收到此错误。任何帮助将不胜感激。
在我的 config.xml 文件中,我具有以下权限:
<plugin name="Camera" value="org.apache.cordova.CameraLauncher"/>
在我的 android 清单中,我有:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />