开发者

Android: Proximity Alert

开发者 https://www.devze.com 2023-04-13 05:56 出处:网络
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 do

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? Th开发者_如何转开发anks in advance!


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.


Fundamental part of Android... Services.

http://developer.android.com/guide/topics/fundamentals/services.html


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.

0

精彩评论

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

关注公众号