我在Android应用程序中拍摄图像时出现问题,按下复选按钮后,应用程序崩溃,
这就是我在logcat中得到的
9 10:33:51.422: E/Trace(27079): error opening trace file: No such file or directory (2)
08-09 10:33:51.717: E/AndroidRuntime(27079): FATAL EXCEPTION: main
08-09 10:33:51.717: E/AndroidRuntime(27079): java.lang.RuntimeException: Unable to resume activity {com.infobia.robocompta/com.infobia.robocompta.MyPhoneGapActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=33, result=-1, data=null} to activity {com.infobia.robocompta/com.infobia.robocompta.MyPhoneGapActivity}: java.lang.NullPointerException
08-09 10:33:51.717: E/AndroidRuntime(27079): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2732)
08-09 10:33:51.717: E/AndroidRuntime(27079): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2760)
08-09 10:33:51.717: E/AndroidRuntime(27079): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2216)
08-09 10:33:51.717: E/AndroidRuntime(27079): at android.app.ActivityThread.access$600(ActivityThread.java:149)
08-09 10:33:51.717: E/AndroidRuntime(27079): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1300)
08-09 10:33:51.717: E/AndroidRuntime(27079): at android.os.Handler.dispatchMessage(Handler.java:99)
08-09 10:33:51.717: E/AndroidRuntime(27079): at android.os.Looper.loop(Looper.java:153)
08-09 10:33:51.717: E/AndroidRuntime(27079): at android.app.ActivityThread.main(ActivityThread.java:5086)
08-09 10:33:51.717: E/AndroidRuntime(27079): at java.lang.reflect.Method.invokeNative(Native Method)
08-09 10:33:51.717: E/AndroidRuntime(27079): at java.lang.reflect.Method.invoke(Method.java:511)
08-09 10:33:51.717: E/AndroidRuntime(27079): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
08-09 10:33:51.717: E/AndroidRuntime(27079): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
08-09 10:33:51.717: E/AndroidRuntime(27079): at dalvik.system.NativeStart.main(Native Method)
08-09 10:33:51.717: E/AndroidRuntime(27079): Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=33, result=-1, data=null} to activity {com.infobia.robocompta/com.infobia.robocompta.MyPhoneGapActivity}: java.lang.NullPointerException
08-09 10:33:51.717: E/AndroidRuntime(27079): at android.app.ActivityThread.deliverResults(ActivityThread.java:3302)
08-09 10:33:51.717: E/AndroidRuntime(27079): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2715)
08-09 10:33:51.717: E/AndroidRuntime(27079): ... 12 more
08-09 10:33:51.717: E/AndroidRuntime(27079): Caused by: java.lang.NullPointerException
08-09 10:33:51.717: E/AndroidRuntime(27079): at org.apache.cordova.DroidGap.onActivityResult(DroidGap.java:850)
08-09 10:33:51.717: E/AndroidRuntime(27079): at android.app.Activity.dispatchActivityResult(Activity.java:5204)
08-09 10:33:51.717: E/AndroidRuntime(27079): at android.app.ActivityThread.deliverResults(ActivityThread.java:3298)
08-09 10:33:51.717: E/AndroidRuntime(27079): ... 13 more
这是相机代码
<pre class="prettyprint">
var myData ="";
function onPhotoDataSuccess(imageData)
{
// alert('onPhotoDataSuccess');
var smallImage = document.getElementById('smallImage');
// Unhide image elements
smallImage.style.display = 'block';
// Show the captured photo
// The inline CSS rules are used to resize the image
smallImage.src = "data:image/jpeg;base64," + imageData;
myData = imageData;
}
function onPhotoURISuccess(imageURI)
{
// Get image handle
//
var largeImage = document.getElementById('largeImage');
// Unhide image elements
//
largeImage.style.display = 'block';
// Show the captured photo
// The inline CSS rules are used to resize the image
largeImage.src = imageURI;
}
function capturePhoto()
{
// Take picture using device camera and retrieve image as base64-encoded string
//alert('capturePhoto');
navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50,destinationType: destinationType.FILE_URI, correctOrientation: true });
}
function capturePhotoEdit()
{
navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 20, allowEdit: true,destinationType: destinationType.FILE_URI });
}
function getPhoto(source)
{
// Retrieve image file location from specified source
navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50,destinationType: destinationType.FILE_URI,sourceType: source });
}
function onFail(message)
{
alert('Failed because: ' + message);
}
我试过了这个foureground插件,但客户并不欣赏它,也取消选中不要保留actitivies。 谢谢。