Android smart power management using sensor data

时间:2015-05-24 20:36:40

标签: android android-sensors

I'm working on an Android application that needs to scan nearby Wi-Fi access points on a regular basis. Currently the scan takes place every 2-3 minutes, which requires registering a BroadcastReceiver to capture the scan results, calling WifiManager's startScan method and processing the results (something that also requires network calls in my case). This loop consumes a lot of energy, and I want to improve my power consumption by implementing a smart power policy for the app.

Aside from scanning only on "busy hours" (for example, stopping the loop at night), I'm thinking about using the accelerometer through the SensorManager to detect whether the device is stationary (placed on a table) or in motion (in the user's pocket while walking, for example). Then, by determining if the device is moving, I can adjust the scan frequency (reduce when it is stationary, and increase when the device is in motion).

I have a few questions on the matter:

1) Will tracking accelerometer data on a regular basis be more power efficient than running the scan loop every 3-5 minutes? How much power will tracking the accelerometer really cost?

2) How can I determine if the device is stationary or in motion? I've seen many question online talking about detecting shakes and tilts, but there's not a lot of information about natural motion detection. Also, how frequently should I sample the sensor?

2 个答案:

答案 0 :(得分:2)

I think the best way is to use ActivityRecognitionApi class included in the google play sevices which is optimized for such goals. This class gives a method : requestActivityUpdates which is optimized to return device state with minimum consumption of power.

The activities are detected by periodically waking up the device and reading short bursts of sensor data. It only makes use of low power sensors in order to keep the power usage to a minimum.

答案 1 :(得分:1)

我是第二个Fouwad Wahabi对你问题的回答。 我建议采用另一种方法来跟踪加速度计和用户的活动。我整合了一个免费的SDK(在线提供),例如: 1. Tranql 诺拉 3. Atooma 其中一些SDK会在用户活动发生时立即向您发送有关活动的详细信息,并且使用的电量不到1%。