Android的 - 当使用LocationManager.requestLocationUpdates,我需要一个WakeLock? [英] Android - When using LocationManager.requestLocationUpdates, do I need a WakeLock?

查看:264
本文介绍了Android的 - 当使用LocationManager.requestLocationUpdates,我需要一个WakeLock?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序会定期检查使用报警到 BroastcastReceiver 启动一个服务的位置。我知道我应该获得一个wakelock开始之前,我的服务,但我什么时候可以释放我的问题是?

My app periodically checks the location using an alarm to a BroastcastReceiver that starts a service. I know I should acquire a wakelock before I start the service but my question is when can I release it?

如果我打电话后释放wakelock requestLocationUpdates ,可以将设备进入睡眠状态,而不是叫我 LocationListener的或将设备总是醒,提供更新,并保持清醒,直到回调返回?我不愿意守住wakelock,因为这将prevent设备的更新,睡,直到我的位置做了。

If I release the wakelock after calling requestLocationUpdates, can the device go to sleep and not call my LocationListener or will the device always wake to deliver updates and stay awake until the callback has returned? I'm reluctant to hold onto the wakelock because that would prevent the device from sleeping between updates until I'm done with the location.

推荐答案

所以,根据我的经验,释放唤醒锁后调用后 requestLocationUpdates 似乎并没有被一个问题。不幸的是,得到一个明确的答案的唯一方法就是问一个平台的开发者,但我已经收到<一href="https://groups.google.com/group/android-developers/browse_thread/thread/facf17b6b392657a/991b6ecfca1918c8?lnk=gst"相对=nofollow>没有回应。

So based on my experience, releasing the wake lock after after calling requestLocationUpdates doesn't seem to be a problem. Unfortunately, the only way to get a definitive answer is to ask a platform developer, but I've received no response.

这篇关于Android的 - 当使用LocationManager.requestLocationUpdates,我需要一个WakeLock?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆