mrmans0n / smart-location-lib

Android library project that lets you manage the location updates to be as painless as possible
1.65k stars 353 forks source link

Getting crash from OnActivityResult #217

Open cears-bhumika opened 6 years ago

cears-bhumika commented 6 years ago

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)

alin-turcu commented 6 years ago

Did you find the solution? I'm getting the same

dsdebastiani commented 6 years ago

I'm getting the same 😞

dsdebastiani commented 6 years ago

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:

1) Disable the location in Android 2) Start the smartLocation to get the location with checkLocationSettings true 3) The dialog asking for enable location will be show 4) In the onActivityResult the Logger will be null 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.