GPS定位和深度睡眠 [英] GPS location and deep sleep
问题描述
我有一个前台服务(与START_STICKY因此对于纵横由OS封杀没问题)接收的位置(GPS)更新每2秒导航的目的。我不采取任何激活锁定。我的问题是:有我采取了激活锁定,以避免深度睡眠?或者位置更新就足以被跑?
I've got a foreground service (with START_STICKY so no problem for the aspect "killed by OS")that receive a location (GPS) update every 2 seconds for navigation purpose. I don't take any wakelock. My question is: have I to take a wakelock to avoid a deep sleep? Or the location updates is enough to be "running"?
推荐答案
后,回应是:不,你不需要它。直到onLocationChange结束或您广播接收机接收的意图Android将抓住你(LocationManagerService)一个激活锁定。如果你做一些异步工作(启动意图服务,邮政onLocationChange等一些code),那么你需要创建自己的部分激活锁定。
After of bit of digging in Android code, the response is: no, you don't need it. Android will grab a wakelock for you (LocationManagerService) until onLocationChange ends or your broadcast receiver receives the intent. If you do some async work (start an intent service, post some code in onLocationChange and so on) then you need to create your own partial wakelock.
这篇关于GPS定位和深度睡眠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!