Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: how to cancel a request of Location update with intent?

Tags:

android

I registered a PendingIntent to requestLocationUpdates(provider, minTime, minDistance, PendingIntent). But when my broadcast receiver receives this intend, how do I remove this request with removeUpdates(PendingIntent)? The receiver doesn't hold a reference to the original PendingIntent.

like image 787
wei Avatar asked Jun 13 '10 08:06

wei


People also ask

How do I stop Android from updating my location?

You can control what location information your phone can use. Open your phone's Settings app. Under "Personal," tap Location access. At the top of the screen, turn Access to my location on or off.

How to request location updates android?

Make a location request Once a location request is in place you can start the regular updates by calling requestLocationUpdates() . Depending on the form of the request, the fused location provider either invokes the LocationCallback.


1 Answers

You create an equivalent PendingIntent. In other words, create an Intent that matches the one you used originally (though you can skip any extras), wrap that in the same sort of PendingIntent that you used originally, and use that PendingIntent in the removeUpdates() call.

like image 135
CommonsWare Avatar answered Oct 06 '22 12:10

CommonsWare