Android accelerometer not working when screen is turned off

前端 未结 6 1648
[愿得一人]
[愿得一人] 2020-11-29 17:38

I\'m developing an application for my final thesis on computer science, and I need to collect and log accelerometer data. I need to acquire it for a whole day long, so there

6条回答
  •  天涯浪人
    2020-11-29 18:18

    I've ran into similar problems with the Samsung Nexus running Android 4.0.2 using other system services that stop/pause while the screen is off even though a PARTIAL_WAKE_LOCK is acquired. My solution was to use a SCREEN_DIM_WAKE_LOCK as in:

     lockStatic = mgr.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK,NAME);
    

    It would be far better to have the screen fully off, but at least this solution works although it would be even better if I could limit using a SCREEN_DIM_WAKE_LOCK to only those devices/OSes that require it.

提交回复
热议问题