简体   繁体   English

后台警报服务

[英]Proximity Alert Service in background

I am developing an application in which i need a proximity alert when the user enter a specific location with a given Latitude, longitude and radius. 我正在开发一个应用程序,当用户输入具有给定纬度,经度和半径的特定位置时,我需要一个接近警报。 I had written a service which implements LocationListener and listen by a BroadcastReceiver to put a notification when the user is in the proximity. 我编写了一个服务,该服务实现LocationListener并由BroadcastReceiver侦听,以在用户接近时发出通知。 Everything working fine, but when i am deleting the application from the recent application list it no more sending the broadcast intent. 一切正常,但是当我从最近的应用程序列表中删除该应用程序时,它不再发送广播意图。 But according to my actual requirement even if the user delete the application from the recent list or the application is not in the background i need to get a notification when the user is in the particular latitude and longitude with the given radius. 但是根据我的实际要求,即使用户从最近的列表中删除该应用程序,或者该应用程序不在后台,当用户处于具有给定半径的特定纬度和经度时,我也需要获得通知。

I think you are doing it wrong. 我认为您做错了。 I would be sure if provided some code in your post. 我可以确定是否在您的帖子中提供了一些代码。

You must use LocationManager for such requirements. 您必须将LocationManager用于此类要求。 Read documentation here . 在此处阅读文档 The first lines say 第一行说

This class provides access to the system location services. 此类提供对系统位置服务的访问。 These services allow applications to obtain periodic updates of the device's geographical location, or to fire an application-specified Intent when the device enters the proximity of a given geographical location. 这些服务允许应用程序获取设备地理位置的定期更新, 或者在设备进入给定地理位置的附近时触发应用程序指定的Intent。

Use its API addProximityAlert to register for an proximity alert even when your app is not running. 即使您的应用未运行,也可以使用其API addProximityAlert注册接近警报。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM