RadiusNetworks / flybuy-android

FlyBuy SDK for Android
Other
5 stars 0 forks source link

IllegalStateException: Not allowed to start service Intent { cmp=****/com.radiusnetworks.flybuy.sdk.service.LocationService } #11

Closed hatched-mariusz closed 4 years ago

hatched-mariusz commented 4 years ago

SDK crashes the app twice per week.

java.lang.IllegalStateException: Not allowed to start service Intent { cmp=**/com.radiusnetworks.flybuy.sdk.service.LocationService }: app is in background* uid UidRecord{1849c6a u0a294 TPSL bg:+3m6s12ms idle change:cached procs:1 proclist:4345, seq(358,358,358)}

It looks like the user quickly run the app and then press the home button quickly. The best solution may be: in method LocationManager#startLocationService add:

try { 
 Intent locationServiceIntent = new Intent(context, LocationService.class);
      context.startService(locationServiceIntent);
} catch (IllegalStateException e){
  //ignote or log to not crash users app
}
botnerd commented 4 years ago

Thank you for reporting this. We'll get a fix in as soon as we can.

botnerd commented 4 years ago

We expect to have a fix for this in the next release and catch the exception so the app doesn't crash. There could be a side effect of the location service not starting properly since it looks like something is trying to trigger the SDK from the background. The location service needs to run as a foreground service so it needs to be started from the foreground. If you're using any background tasks, push messages, etc to trigger this, you may need to prompt the user via a notification or other method to open the app so it's in the foreground.

botnerd commented 4 years ago

This has been fixed in v1.3.1. Please note the potential side effect in the previous comment. I'm going to close this issue. If you continue to see any issues, please comment or open a new issue.