Is it possible to detect motion when screen is off?

后端 未结 4 407
情深已故
情深已故 2021-01-13 02:24

My app simply need to detect any motion of the device while screen is off.

I know that accelerometer is used for this task but it don\'t work while screen is off in

4条回答
  •  一整个雨季
    2021-01-13 03:26

    Yes you can use accelerometer in the background or when screen is off
    but you need to hold a WakeLock [Link] to prevent the device from sleeping.

    If you need to detect if the device is still or if it started moving again you might be interested in Recognizing the User's Current Activity from Google Services.

提交回复
热议问题