Skip to content

fixed java.lang.NullPointerException at com.synconset.ImagePicker.onActivityResult(ImagePicker.java:67)#171

Open
kuwabarahiroshi wants to merge 1 commit intowymsee:masterfrom
kuwabarahiroshi:fix/null-pointer-exception
Open

fixed java.lang.NullPointerException at com.synconset.ImagePicker.onActivityResult(ImagePicker.java:67)#171
kuwabarahiroshi wants to merge 1 commit intowymsee:masterfrom
kuwabarahiroshi:fix/null-pointer-exception

Conversation

@kuwabarahiroshi
Copy link

@kuwabarahiroshi kuwabarahiroshi commented Aug 30, 2016

I had encountered an error as below:

08-30 10:26:08.321  8131  8131 E AndroidRuntime: java.lang.RuntimeException: Unable to resume activity {com.lifullfam.app/com.lifullfam.app.MainActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=0, result=-1, data=Intent { (has extras) }} to activity {com.lifullfam.app/com.lifullfam.app.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void org.apache.cordova.CallbackContext.success(org.json.JSONArray)' on a null object reference
08-30 10:26:08.321  8131  8131 E AndroidRuntime:    at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3103)
08-30 10:26:08.321  8131  8131 E AndroidRuntime:    at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3134)
08-30 10:26:08.321  8131  8131 E AndroidRuntime:    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2481)
08-30 10:26:08.321  8131  8131 E AndroidRuntime:    at android.app.ActivityThread.-wrap11(ActivityThread.java)
08-30 10:26:08.321  8131  8131 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
08-30 10:26:08.321  8131  8131 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:102)
08-30 10:26:08.321  8131  8131 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:148)
08-30 10:26:08.321  8131  8131 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:5417)
08-30 10:26:08.321  8131  8131 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
08-30 10:26:08.321  8131  8131 E AndroidRuntime:    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
08-30 10:26:08.321  8131  8131 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
08-30 10:26:08.321  8131  8131 E AndroidRuntime:    at android.app.ActivityThread.deliverResults(ActivityThread.java:3699)
08-30 10:26:08.321  8131  8131 E AndroidRuntime:    at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3089)
08-30 10:26:08.321  8131  8131 E AndroidRuntime:    ... 10 more
08-30 10:26:08.321  8131  8131 E AndroidRuntime:    at com.synconset.ImagePicker.onActivityResult(ImagePicker.java:67)
08-30 10:26:08.321  8131  8131 E AndroidRuntime:    at org.apache.cordova.CordovaInterfaceImpl.onActivityResult(CordovaInterfaceImpl.java:151)
08-30 10:26:08.321  8131  8131 E AndroidRuntime:    at org.apache.cordova.CordovaActivity.onActivityResult(CordovaActivity.java:348)
08-30 10:26:08.321  8131  8131 E AndroidRuntime:    at android.app.Activity.dispatchActivityResult(Activity.java:6428)
08-30 10:26:08.321  8131  8131 E AndroidRuntime:    at android.app.ActivityThread.deliverResults(ActivityThread.java:3695)
08-30 10:26:08.321  8131  8131 E AndroidRuntime:    ... 11 more

The error seems to be related with CB-9189, which was fixed by this apache/cordova-plugin-camera#145.

This PR fixes the case when the CordovaActivity was killed by the android OS while launching another Activity.
This might also fixes #170.

This fixed java.lang.NullPointerException at `com.synconset.ImagePicker.onActivityResult(ImagePicker.java:67)` when the CordovaActivity is killed by the OS.
@kuwabarahiroshi
Copy link
Author

FYI, this NullPointerException can be reproduced by enabling Don't keep activities option in Developer options.

genymotion_for_personal_use_-_google_nexus_6_-_6_0_0_-_api_23_-_1440x2560__1440x2560__560dpi__-_192_168_61_101

@Spriz
Copy link

Spriz commented Mar 22, 2017

Hi there! I took the liberty of merging your changes to my fork at https://github.com/Spriz/cordova-imagePicker :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

App crashes on Android 5.0.1

2 participants