android – 检索数据时Phonegap相机故障

前端之家收集整理的这篇文章主要介绍了android – 检索数据时Phonegap相机故障前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
—————更新—————

似乎HTC Desire相机和这个版本的Phonegap存在某种问题.问题似乎是HTC在Android上返回相机规格的方式.

—————更新—————

我一直在使用phonegap重写我以前的应用程序的代码,但不是我需要使用相机API.当我在真正的手机上使用它时拍摄照片后崩溃了,我在SendLog中遇到了这个错误.

  1. 10-07 09:44:46.980 D/AndroidRuntime( 1626): Shutting down VM
  2. 10-07 09:44:46.980 W/dalvikvm( 1626): threadid=1: thread exiting with uncaught exception (group=0x400259f8)
  3. 10-07 09:44:46.989 W/CameraThread( 1159): Release Camera - set mIsLastCameraClosed to true
  4. 10-07 09:44:46.989 W/CameraThread( 1159): CameraHandler Message - CLOSE_CAMERA end
  5. 10-07 09:44:46.989 E/AndroidRuntime( 1626): FATAL EXCEPTION: main
  6. 10-07 09:44:46.989 E/AndroidRuntime( 1626): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null,request=33,result=-1,data=Intent { act=inline-data (has extras) }} to activity {com.theinit.example/com.theinit.example.TestPhoneGapActivity}: java.lang.NullPointerException
  7. 10-07 09:44:46.989 E/AndroidRuntime( 1626): at android.app.ActivityThread.deliverResults(ActivityThread.java:3734)
  8. 10-07 09:44:46.989 E/AndroidRuntime( 1626): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3776)
  9. 10-07 09:44:46.989 E/AndroidRuntime( 1626): at android.app.ActivityThread.access$2800(ActivityThread.java:135)
  10. 10-07 09:44:46.989 E/AndroidRuntime( 1626): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2166)
  11. 10-07 09:44:46.989 E/AndroidRuntime( 1626): at android.os.Handler.dispatchMessage(Handler.java:99)
  12. 10-07 09:44:46.989 E/AndroidRuntime( 1626): at android.os.Looper.loop(Looper.java:144)
  13. 10-07 09:44:46.989 E/AndroidRuntime( 1626): at android.app.ActivityThread.main(ActivityThread.java:4937)
  14. 10-07 09:44:46.989 E/AndroidRuntime( 1626): at java.lang.reflect.Method.invokeNative(Native Method)
  15. 10-07 09:44:46.989 E/AndroidRuntime( 1626): at java.lang.reflect.Method.invoke(Method.java:521)
  16. 10-07 09:44:46.989 E/AndroidRuntime( 1626): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
  17. 10-07 09:44:46.989 E/AndroidRuntime( 1626): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
  18. 10-07 09:44:46.989 E/AndroidRuntime( 1626): at dalvik.system.NativeStart.main(Native Method)
  19. 10-07 09:44:46.989 E/AndroidRuntime( 1626): Caused by: java.lang.NullPointerException
  20. 10-07 09:44:46.989 E/AndroidRuntime( 1626): at android.content.ContentResolver.openInputStream(ContentResolver.java:286)
  21. 10-07 09:44:46.989 E/AndroidRuntime( 1626): at com.phonegap.CameraLauncher.onActivityResult(CameraLauncher.java:248)
  22. 10-07 09:44:46.989 E/AndroidRuntime( 1626): at com.phonegap.DroidGap.onActivityResult(DroidGap.java:1346)
  23. 10-07 09:44:46.989 E/AndroidRuntime( 1626): at android.app.Activity.dispatchActivityResult(Activity.java:3931)
  24. 10-07 09:44:46.989 E/AndroidRuntime( 1626): at android.app.ActivityThread.deliverResults(ActivityThread.java:3730)
  25. 10-07 09:44:46.989 E/AndroidRuntime( 1626): ... 11 more

有谁知道为什么会这样?

这是我的Camera.js

这是我的Camera.js

  1. var options = { quality : 75,destinationType : Camera.DestinationType.DATA_URL,sourceType : Camera.PictureSourceType.CAMERA,allowEdit : true,targetWidth: 100,targetHeight: 100 };
  2.  
  3. function capturePhoto() {
  4. // Take picture using device camera and retrieve image as base64-encoded string
  5. navigator.camera.getPicture(onPhotoDataSuccess,onFail,options);
  6. }
  7.  
  8. function onPhotoDataSuccess() {
  9. // Uncomment to view the base64 encoded image data
  10. var theHTML = '';
  11. theHTML = '<div id="info">CameraSuccess</div>';
  12. document.getElementById('main').innerHTML = theHTML;
  13. }
  14.  
  15. function onFail(message) {
  16. // Called if something bad happens.
  17. alert('Failed because: ' + message);
  18. }

希望能帮助到你

谢谢大家

解决方法

我刚刚在PhoneGap问题列表中帮助了一个有同样错误的人.我相信你错过了许可:
  1. <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

来自您的AndroidManifest.xml文件.我们需要能够将捕获的图像写入.jpg文件.

猜你在找的Android相关文章