-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NullPointerException - Samsung Galaxy S4 - Android 5.0.1 #9
Comments
Same error I am getting in OS 6. Is there any solution? |
Probably after taking camera image or picking image from gallery, the device was rotated, so the activity is destroyed and the ImagePicker object is null. Good luck |
This is a problem that many samsung have, as their camera app, rotates to take a picture. I tried to save the state, but it is not a serializable object. @Omid3d do you have some ideas? |
Yes you can't serialize this object and you shouldn't. My recommendation is to recreate object wherever you want to access that. Because after camera rotates you just need to call ImagePicker.handleActivityResult in onActivityResult and I think we can safely get the result from intent. Also think about image pick callback, can we save state of a callback? Maybe no!
and then whenever you want to access to this ImagePicker object call this method and instead of serializing ImagePicker object or something else, just save state of selectedImageUri or taken image uri in activity. So after onActivityResult called you have your object and it can handle the result without any problem. Also don't forget to first call this method in oncreate (to ensure you receive callback from ImagePicker). I hope my answer as a workaround can help you to solve this problem. |
05-27 14:45:15.592 6787-6787/com.myhexaville.androidimagepicker E/AndroidRuntime: FATAL EXCEPTION: main Process: com.myhexaville.androidimagepicker, PID: 6787 java.lang.RuntimeException: Unable to resume activity {com.myhexaville.androidimagepicker/com.myhexaville.androidimagepicker.activity_example.ActivityExample}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=200, result=-1, data=null} to activity {com.myhexaville.androidimagepicker/com.myhexaville.androidimagepicker.activity_example.ActivityExample}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.myhexaville.smartimagepicker.ImagePicker.handleActivityResult(int, int, android.content.Intent)' on a null object reference at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3394) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3425) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2763) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4462) at android.app.ActivityThread.access$1000(ActivityThread.java:177) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1454) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:5942) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195) Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=200, result=-1, data=null} to activity {com.myhexaville.androidimagepicker/com.myhexaville.androidimagepicker.activity_example.ActivityExample}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.myhexaville.smartimagepicker.ImagePicker.handleActivityResult(int, int, android.content.Intent)' on a null object reference at android.app.ActivityThread.deliverResults(ActivityThread.java:4058) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3380) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3425) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2763) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4462) at android.app.ActivityThread.access$1000(ActivityThread.java:177) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1454) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:5942) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.myhexaville.smartimagepicker.ImagePicker.handleActivityResult(int, int, android.content.Intent)' on a null object reference at com.myhexaville.androidimagepicker.activity_example.ActivityExample.onActivityResult(ActivityExample.java:31) at android.app.Activity.dispatchActivityResult(Activity.java:6549) at android.app.ActivityThread.deliverResults(ActivityThread.java:4054) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3380) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3425) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2763) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4462) at android.app.ActivityThread.access$1000(ActivityThread.java:177) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1454) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:5942) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
The text was updated successfully, but these errors were encountered: