开发者

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

开发者 https://www.devze.com 2023-01-03 02:25 出处:网络
I registered a PendingIntent to requestLocationUpdates(provid开发者_JAVA百科er, minTime, minDistance, PendingIntent). But when my broadcast receiver receives this intend, how do I remove this request

I registered a PendingIntent to requestLocationUpdates(provid开发者_JAVA百科er, 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消