Android:接近警报

发布于 2024-12-10 02:12:02 字数 208 浏览 2 评论 0原文

我已按照本教程了解如何使用接近度警报以及如何注册它。 这一切都有效,但是当我关闭应用程序(使用后退按钮,而不是主页按钮)时,接近警报不再起作用。有谁知道如何设置它以使其在后台运行? 提前致谢!

I have followed this tutorial about how to use the proximity alert and how to register it.
It all works but when I close the app (with the back button, not the home-button) then the proximity alert does not work anymore. Does anyone know how to set it so that it runs in the background?
Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

纸短情长 2024-12-17 02:12:02

当您的应用程序未运行时,您似乎无法获取位置更新。在后台接收位置更新不是一个好主意,因为它会耗尽电池电量,并且用户可能不知道位置正在被跟踪,因为按应用程序上的后退按钮的正常行为是关闭所有服务。如果我希望我的应用程序继续在后台运行,我作为用户会按主页按钮。

查看“我的足迹”应用程序使用的模型。
另请参阅 Android 有关位置和使用模型的文档:
http://developer.android.com/guide/topics/location /obtaining-user-location.html

如果您已经了解了不让应用程序在后台执行此操作但仍希望在后台运行的原因,请查看服务
http://developer.android.com/reference/android/app/Service.html
它们可以在后台运行,并在需要时为您的应用程序提供数据。

It seems that you can not get location updates when your application is not running. Receiving location updates in the background is not a good idea since it drains battery power and the user might not be aware that the location is being tracked since the normal behavior for pressing the back button on the application is for it to close all services. If I want my application to continue running in the background, I as a user would press the home button.

Look at the model used by the "My Tracks" application.
Also see the documentation from Android on locations and usage models:
http://developer.android.com/guide/topics/location/obtaining-user-location.html

If you have informed yourself about the reasons not to have the application do this in the background but still want to run this in the background, look into Services
http://developer.android.com/reference/android/app/Service.html
They can run in the background and provide your application with data when asked.

茶花眉 2024-12-17 02:12:02

如果您注册了它,您应该会收到它,但请记住,如果您的屏幕关闭,接近警报可能不会立即发出。如果您的屏幕关闭,则每 4 分钟探测一次位置,如 文档

You should get it if you register for it, but keep in mind that proximity alert may not be immediate if your screen is off. If your screen is off, then location is probed for every 4 minutes as stated in the documentation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文