smart-location-lib icon indicating copy to clipboard operation
smart-location-lib copied to clipboard

Getting crash from OnActivityResult

Open cears-bhumika opened this issue 7 years ago • 3 comments

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)

cears-bhumika avatar Oct 09 '17 05:10 cears-bhumika

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

alin-turcu avatar Nov 29 '17 07:11 alin-turcu

I'm getting the same 😞

dsdebastiani avatar Jan 29 '18 20:01 dsdebastiani

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.

dsdebastiani avatar Jan 30 '18 12:01 dsdebastiani