开发者

Determine Android phone's proximity to known point while conserving power

开发者 https://www.devze.com 2023-01-03 13:55 出处:网络
I am trying to determine if an Android user has had a close proximity to a list of predetermined locations. I\'d like to do this with the least amount of drain on the phone\'s battery. The two mechani

I am trying to determine if an Android user has had a close proximity to a list of predetermined locations. I'd like to do this with the least amount of drain on the phone's battery. The two mechanisms I see for accomplishing this are proximity alerts and requesting location updates. What are the pros and cons of the two methods? Will one have less affect on the battery than the other? In either case I would guess the specific location manager used would have some affect power usage (existing Stack Overflow answ开发者_高级运维er).


Location updates are probably less expensive than proximity alerts in terms of battery usage.

Since addProximityAlert uses both NETWORK_PROVIDER and GPS_PROVIDER, you lose the ability to pick which provider you want to use. Additionally, while the documentation suggests that it limits proximity checks to once every four minutes when the screen is off, I can't find the code to support such functionality and what I can find is essentially a call to requestLocationUpdates with a minimum time interval hint of 1000 ms. Since it is recommended that background services use values over 60000 ms, I suspect that it would be less expensive to call requestLocationUpdates directy with a large minimum time interval and NETWORK_PROVIDER.

0

精彩评论

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