java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=intent} to activity

android, java, lang, runtimeexception

Solution

`getDrawable` is returning null in your case. The uri that you are using for `setImageURI` may not be valid, hence you are getting null.

Do a null check for drawable, if drawable is null , you need to bail.

Edit:

if(drawable == null)
  return;

Problem

In my app I hit a button called Pick Photo and it loads the gallery. When I click an image in the gallery, the app force closes and in my logcat I receive the following: ``` java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { dat=content://media/external/images/media/3369 (has extras) }} to activity {cap.shot/cap.shot.LolcatActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2655) at android.app.ActivityThread.handleSendResult(ActivityThread.java:2697) at android.app.ActivityThread.access$2000(ActivityThread.java:124) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:998) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3806) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at cap.shot.LolcatView.loadFromUri(LolcatView.java:137) at cap.shot.LolcatActivity.loadPhoto(LolcatActivity.java:384) at cap.shot.LolcatActivity.onActivityResult(LolcatActivity.java:299) at android.app.Activity.dispatchActivityResult(Activity.java:3988) at android.app.ActivityThread.deliverResults(ActivityThread.java:2651) ``` My lolcatactivity.java is available here: http://pastebin.com/AVL8CswT My lolcatview.java is available here: http://pastebin.com/vD7vCBgY Thank you!

Original source