Android的:如何取消位置更新的意图的要求? [英] Android: how to cancel a request of Location update with intent?

查看:88
本文介绍了Android的:如何取消位置更新的意图的要求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注册了一个PendingIntent到requestLocationUpdates(供应商,minTime,minDistance依旧,PendingIntent)。但是,当我的广播接收器接收到这个打算,我怎么删除此请求,removeUpdates(PendingIntent)?接收器无法保持参照原有PendingIntent。

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.

推荐答案

您创建一个等效 PendingIntent 。换句话说,创建一个意图匹配您最初使用(虽然你可以跳过任何额外的)一个,包在同一类 PendingIntent的您最初使用,并使用 PendingIntent removeUpdates()通话。

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.

这篇关于Android的:如何取消位置更新的意图的要求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆