Why onSensorChange is not invoked when Wearable device is in Ambient Mode

强颜欢笑 提交于 2019-12-06 13:56:30

1.When system is in ambient mode, CPU performs as the same as normal, that means most time during ambient mode, the CPU is sleeping. So unless the sensor is an wake-up sensor, it cannot wake up the system, so you won't receive the onSensorChanged. The reason why it work in pluging USB is that when debug with USB, CPU do not sleep.

2.Ambient does have a mechanism to keep system awake, but the only situation that CPU should not sleep is that CPU is doing drawing action(usually refreshing the clock wallpaper). Ambient is meant to save power, so add wake lock in activity is a bad idea.

3.The code you post seems that you registered a TYPE_ACCELEROMETER sensor, this sensor has a wakeUp version and a non-wakeUp version, may be try the latter one.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!