Android“传递结果 ResultInfo 失败”当意图不为空时
我的动态壁纸中有一个自定义图像首选项,允许用户从 SD 卡中选择图像用作背景。我从此处获取了代码,并且没有修改它,所以它几乎完全是除了变量或对象名称之外,其他都相同。
我在我的开发控制台中收到了一些堆栈跟踪:
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { dat=file:///mnt/sdcard/com.idunnolol.rageface/rage_fullpanel.png }} to activity {gilleland.software.pixelrain/gilleland.software.pixelrain.PixelRainSettings}: java.lang.NullPointerException
at android.app.ActivityThread.deliverResults(ActivityThread.java:3515)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3557)
at android.app.ActivityThread.access$2800(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2063)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at gilleland.software.pixelrain.PixelRainSettings.getRealPathFromURI(PixelRainSettings.java:107)
at gilleland.software.pixelrain.PixelRainSettings.onActivityResult(PixelRainSettings.java:90)
at android.app.Activity.dispatchActivityResult(Activity.java:3890)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3511)
... 11 more
我在自己的手机上没有收到此异常。
我已经搜索了一段时间来找出导致 NullPointerException 的原因,但我发现的大多数解决方案都涉及“ResultInfo{who=null, request=1, result=-1, data=null}”。我得到的堆栈跟踪实际上有数据意图......所以我无法弄清楚 NullPointerException 是来自什么。
感谢任何和所有的帮助。我可以提供任何必要的代码来帮助解决这个问题。 谢谢!
I have a custom image preference in my Live Wallpaper that allows a user to choose an image from their SD card to use as a background. I got the code from here and haven't modified it, so it's almost exactly the same except for variable or object names.
I've been getting a few of these stack traces in my dev console:
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { dat=file:///mnt/sdcard/com.idunnolol.rageface/rage_fullpanel.png }} to activity {gilleland.software.pixelrain/gilleland.software.pixelrain.PixelRainSettings}: java.lang.NullPointerException
at android.app.ActivityThread.deliverResults(ActivityThread.java:3515)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3557)
at android.app.ActivityThread.access$2800(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2063)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at gilleland.software.pixelrain.PixelRainSettings.getRealPathFromURI(PixelRainSettings.java:107)
at gilleland.software.pixelrain.PixelRainSettings.onActivityResult(PixelRainSettings.java:90)
at android.app.Activity.dispatchActivityResult(Activity.java:3890)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3511)
... 11 more
I don't get this exception on my own phone.
I've been searching for a while to figure out what's causing the NullPointerException but most of the solutions I have found involve "ResultInfo{who=null, request=1, result=-1, data=null}". The stack traces I'm getting actually have Intents with data...so I can't figure out what the NullPointerException is from.
Any and all help is appreciated. I can provide any necessary code to help solve this.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
requestCode 和 resultCode 是正确的,所以我猜问题是由于以下代码部分中的变量指针之一未正确初始化:
它可能与 selectedImage 或 RealPath 相关。注释掉大部分代码,逐行调试。
The requestCode and resultCode is correct, so I guess the problem is due to one of the variable pointer is not properly initialized in following section of code:
It's probably something related to the selectedImage or RealPath. Comment out most of the codes and debug it line by line.