2

I'm Using Fused location provider to get frequent location updates based on the users need. Using BroadCast Reciever to recieve the location updates with the LocationRequest Class.

Using pending intent I'm initializing the reciever.

    mPendingIntent = PendingIntent.getBroadcast(this, 1, mIntentService, 0);

And getting the Location updates from fusion provider.

LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient,mLocationRequest, mPendingIntent);

All these are going well for certain period of time. After some time say for 2 hours or more then suddenly the BroadCast Reciever is not recieving any updates and its so unusual that there is no reason why it got stopped.

I haven't stopped the application or Stopped recieving the location update from the FusedLocationApi

S A R
  • 146
  • 3
  • 20
  • Did you look at the logcat? Is there anything interesting in there? Also, is this only on Marshmallow or also older apis? – Shmuel Jan 05 '16 at 14:09
  • [This SO issue](http://stackoverflow.com/questions/34279773/fusedlocationapi-background-location-service-stops-receiving-updates-randomly) might be related to your inquiry. – adjuremods Jan 06 '16 at 02:01
  • @Shmuel Not specified to any versions, its common. Nothing special in the logcat – S A R Jan 06 '16 at 09:25
  • @adjuremods There is no accepted answer in it any how i'll try it. – S A R Jan 06 '16 at 09:27

1 Answers1

0

I think Nothing wrong in your FusedLocationApi. The problem is BroadcastReceiver.

A process that is currently executing a BroadcastReceiver (that is, currently running the code in its onReceive(Context, Intent) method) is considered to be a foreground process and will be kept running by the system except under cases of extreme memory pressure.

Once you return from onReceive(), the BroadcastReceiver is no longer active.

This means that for longer-running operations you will often use a Service in conjunction with a BroadcastReceiver to keep the containing process active for the entire time of your operation.

For more click here

sivaBE35
  • 1,876
  • 18
  • 23