Android : Google Play Services: how to check if there is currently "active" pending intent callback registered to location updates/activity recognition?

on Thursday, August 7, 2014


my application perform periodic location updates and Activity recognition detection in background.


I'm doing that using the Google Play Services API's:


for example - to register to location updates, I provide pending intent to receive update:



mLocationClient.requestLocationUpdates(mLocationRequest, pendingInent);


to unregister to location update, I'm doing the following:



mLocationClient.removeLocationUpdates(pendingInent);


that's nice, and working great.


but how can I find out if currently location updates are active or not?


I notices that there is no API to check this, and the approach to check for pendingIntent existence seems not to work for API's against google play services - the pending intent stays exists even after I call the removeLocationUpdates() method.


I know I can save state (to shared preferences) indicating if now I'm registered or not, but it's not the right solution, and will be "buggy" because it can happen that google play process went down, lost the pendingIntent, but my process will still think that the location updates are "active"..


same problem exactly exists for the activity recognition updates.


Thanks in advance.


0 comments:

Post a Comment