smart-location-lib
smart-location-lib copied to clipboard
Getting crash from OnActivityResult
Hi, I'm getting crash from the below line from onActivityResult in fragment. if (provider != null) { provider.onActivityResult(requestCode, resultCode, data); }
here is my crash log:
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=20001, result=-1, data=Intent { (has extras) }} to activity {xxx.activity.main.MainActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'void io.nlopez.smartlocation.utils.Logger.i(java.lang.String, java.lang.Object[])' on a null object reference at android.app.ActivityThread.deliverResults(ActivityThread.java:5004) at android.app.ActivityThread.handleSendResult(ActivityThread.java:5047) at android.app.ActivityThread.access$1600(ActivityThread.java:229) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1875) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:7331) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void io.nlopez.smartlocation.utils.Logger.i(java.lang.String, java.lang.Object[])' on a null object reference at io.nlopez.smartlocation.location.providers.LocationGooglePlayServicesProvider.onActivityResult(LocationGooglePlayServicesProvider.java:325) at xxx.xxx.xxxFragment.onActivityResult(xxxFragment.java:265) at xxx.xxx.xxxActivity.onActivityResult(MainActivity.java:422)
Did you find the solution? I'm getting the same
I'm getting the same 😞
There is a problem with Logger
in the LocationGooglePlayServicesProvider
at onActivityResult
method. For some reason the logger
object is null
.
Steps to reproduce the error:
- Disable the location in Android
- Start the smartLocation to get the location with
checkLocationSettings
true - The dialog asking for enable location will be show
- In the
onActivityResult
the Logger will benull
and the crashes occours
I'm usig the library in a Fragment too. So, I belive that the problem could be solved with the support to Fragments in the provider. How was suggested in PL #197.