【发布时间】:2014-11-01 07:10:41
【问题描述】:
我只在KitKat 设备上遇到onActivityResult 的问题,当用户选择图像或应用程序获取force closed 的任何文件时,我从谷歌开发者控制台检查了崩溃和ANRS,我发现了这个错误
堆栈跟踪 1.1:应用程序版本 Android 版本 4.3 Y530 (hwY530-U00) 设备 java.lang.RuntimeException:无法恢复 活动 {packageName.New_Post}: java.lang.RuntimeException:传递结果失败 ResultInfo{who=null, request=2803, result=-1, data=Intent { dat=content://media/external/images/media/3528 flg=0x1 }} 到活动 {packageName.New_Post}: java.lang.NullPointerException 在 android.app.ActivityThread.performResumeActivity(ActivityThread.java:3012) 在 android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3041) 在 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2393) 在 android.app.ActivityThread.access$900(ActivityThread.java:148) 在 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1319) 在 android.os.Handler.dispatchMessage(Handler.java:99) 在 android.os.Looper.loop(Looper.java:137) 在 android.app.ActivityThread.main(ActivityThread.java:5457) 在 java.lang.reflect.Method.invokeNative(Native Method) 在 java.lang.reflect.Method.invoke(Method.java:525) 在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:854) 在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670) 在 dalvik.system.NativeStart.main(Native Method) 原因: java.lang.RuntimeException:传递结果失败 ResultInfo{who=null, request=2803, result=-1, data=Intent { dat=content://media/external/images/media/3528 flg=0x1 }} 到活动 {packageName.New_Post}: java.lang.NullPointerException 在 android.app.ActivityThread.deliverResults(ActivityThread.java:3614) 在 android.app.ActivityThread.performResumeActivity(ActivityThread.java:2999) ... 12 更多原因:java.lang.NullPointerException at packageName.New_Post.onActivityResult(New_Post.java:343) 在 android.app.Activity.dispatchActivityResult(Activity.java:5442) 在 android.app.ActivityThread.deliverResults(ActivityThread.java:3610)
这是代码:
protected void onActivityResult(int requestCode, int resultCode, 意图数据){
//if Sent from Attachment File Send information Back to It if ( requestCode == Api.UPLOAD_ATTACHMENT ) { if (resultCode == RESULT_OK) { Uri uri = data.getData(); ContentValues info = new ContentValues(); info.put("posthash", posthash); info.put("poststarttime", poststarttime); info.put("t", ShowThread.thread.threadid); info.put("p", p); info.put("editpost", 0); info.put("f", ShowThread.thread.forumid); info.put("perm", ( attcperm != null ) ? attcperm.toString() : ""); new Attachment_upload( context , uri , info ,attachments_box); } } }
我不明白我有resultCode == RESULT_OK 所以如果应用程序没有返回附件文件那么为什么结果是好的?
【问题讨论】:
标签: java android eclipse android-intent nullpointerexception