收到接近警报意图时如何接收位置信息?
我需要使用 LocationManager 中的 addProximityAlert 方法添加多个接近警报。问题是,当我收到通知用户接近我正在侦听警报的区域之一的意图时,如果用户正在读取 KEY_PROXIMITY_ENTERING 的区域进入或退出,我可以获得,但我不知道该区域是什么他正在进入或退出。有什么办法可以获取此类信息吗?
I need to add more than one proximity alert with addProximityAlert method from LocationManager. The problem is that when i receive the intent informing that the user is near to one of the regions that i am listening for alerts i can get if the user is entering or exiting in a region reading KEY_PROXIMITY_ENTERING, but i dont know what is the region he is entering or exiting. Is there any way the get this kind of info?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,要添加 ProximityAlert,您需要一个 PendingIntent,可以使用 PendingIntent.getBroadcast(aContext, aRequestCode, anIntent, 0); 获取 PeindingIntent;现在,在第三个参数“anIntent”中,您可以放置任何您想要的数据,例如位置对象,通过位置获取的城市名称,
我这样做:
现在,当您收到广播消息时,您必须获取位置来自传递的意图的信息,类似这样;
干杯
well, to add a ProximityAlert you need a PendingIntent, a PeindingIntent can be obtained with PendingIntent.getBroadcast(aContext, aRequestCode, anIntent, 0); Now, in the third parameter 'anIntent' you can put any data you want, like a Location object, a city name obtained with the location,
i do this like this:
now, when you receive the broadcast message, you must obtain the location info from the passed intent, something like this;
cheers
为您感兴趣的每个区域定义多个操作
Define multiple Actions for every region you are interested in