gpt4 book ai didi

java - Android KitKat 传递结果 ResultInfo 失败?

转载 作者:太空狗 更新时间:2023-10-29 15:01:53 30 4
gpt4 key购买 nike

我只在 KitKat 设备上遇到 onActivityResult 问题,当用户选择图像或任何文件时,应用程序会强制关闭,我检查过来自谷歌开发者控制台的崩溃和 ANRS,我发现了这个错误

STACK TRACES 1.1:Application version Android version 4.3 Y530 (hwY530-U00) Device java.lang.RuntimeException: Unable to resume activity {packageName.New_Post}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=2803, result=-1, data=Intent { dat=content://media/external/images/media/3528 flg=0x1 }} to activity {packageName.New_Post}: java.lang.NullPointerException at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3012) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3041) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2393) at android.app.ActivityThread.access$900(ActivityThread.java:148) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1319) at 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) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=2803, result=-1, data=Intent { dat=content://media/external/images/media/3528 flg=0x1 }} to activity {packageName.New_Post}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:3614) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2999) ... 12 more Caused by: 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, Intent data) {

  //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 所以如果应用程序没有返回附件文件那么为什么结果是好的?

最佳答案

你的URI不正确请尝试获取绝对路径

关于java - Android KitKat 传递结果 ResultInfo 失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25717928/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com