onActivityResult
只在KitKat
设备上出现问题,当用户选择的图片或应用获取的任何文件force closed
时,我检查了Crashes&来自谷歌开发者控制台的ANRS,我发现了这个错误
STACK TRACES 1.1:应用程序版本Android版本4.3 Y530 (hwY530-U00)设备java.lang.RuntimeException:无法恢复 activity {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 at 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)at android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1319) 在android.os.Handler.dispatchMessage(Handler.java:99)at android.os.Looper.loop(Looper.java:137)at android.app.ActivityThread.main(ActivityThread.java:5457)at java.lang.reflect.Method.invokeNative(Native Method)at java.lang.reflect.Method.invoke(Method.java:525)at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:854) 在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)at dalvik.system.NativeStart.main(Native方法)引起: 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 at android.app.ActivityThread.deliverResults(ActivityThread.java:3614)at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2999) ... 12更多引起:java.lang.NullPointerException at packageName.New_Post.onActivityResult(New_Post.java:343)at android.app.Activity.dispatchActivityResult(Activity.java:5442)at 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
所以如果申请人没有返回附件文件那么为什么结果还可以呢?
答案 0 :(得分:0)
您的URI不正确请尝试获取绝对路径