Android sensor listening when app in background

前端 未结 1 915
广开言路
广开言路 2020-12-31 08:26

Is it possible to track motion sensor events on Android continuously, even if the app is not in foreground?

If yes - what\'s the drain on battery?

A client a

相关标签:
1条回答
  • 2020-12-31 08:59

    First, you can definitely monitor the sensors in the background. You need to use a service for that type of application. Here is an example of someone creating a barometer data logger. There's not really any reason you couldn't use different sensors.

    Second, as far as I'm aware, running the sensors continuously like that would drain the battery quickly. This presentation suggests that depending on your sampling speed, you could burn through about 4% of the battery per hour on the sensor use.

    Lastly, you can definitely wake the phone and take action upon an event received by that service. See this question.

    0 讨论(0)
提交回复
热议问题