服务与待机
我有一个后台服务,可以在手机倒置时使用传感器加速度计进行控制以及是否是真正的手机声音。如果我运行该服务并将手机倒置,那就没问题,但如果我按下电源按钮并启用锁定屏幕,手机就不会发出声音。我不明白服务是否已停止或者是sensorchangelistener。我还使用了 onCreate 的wakelock.acquire方法,但它适用于我的手机(galaxy s),但不适用于我朋友的手机(motorolo defy)..你能帮助我吗? :-(
I have a background Service that control with sensor accelerometer when the phone is upside down and if it's true phone sound. If I run the service and put my phone upside down it's ok but if I push power button and able a lock screen the phone not sound. I don't understand if the service is stopped or is the sensorchangelistener. i have also used into onCreate the wakelock.acquire method but it work good with my phone (galaxy s) but not work with phone of my friend (motorolo defy).. Can you help me? :-(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当手机处于待机状态时,甚至在部分唤醒锁定的情况下,无法使用传感器。您需要完整的唤醒锁才能持续接收传感器更新。据说有些手机有一个解决方法,一旦手机进入待机状态,您可以再次请求传感器更新,但这仅适用于少数手机,并且很难成为可靠的解决方案。所以简而言之,唯一的办法就是让手机保持唤醒状态。
It's not possible to use sensors while the phone is in standby, or even with a partial wake lock. You need a full wake lock to keep receiving sensor updates. Supposedly some phones have a workaround, in that once the phone goes into standby you can request sensor updates again, but this only works for a few phones, and is hardly a reliable solution. So in short, the only way is to keep the phone awake.