Retrieving Android Battery Metrics Every n Seconds [Efficiently]
<p>I have found numerous sources for monitoring battery levels, but none of them describe how to check it at a fixed time interval. Suppose I want to check the battery every n seconds. What is the most efficient way to do this?</p>

<p>Currently, I create a BroadcastReceiver and register it in my service with a filter. I then use a ScheduledExecutor to "fetch" the information from the battery. If I understand what's going on correctly, the BroadcastReceiver I made receives all broadcasts from the battery rather at a dynamic rate as they come in, rather than the constant rate I want to check it at.</p>

<p>It appears that when I create the BroadcastReceiver, it receives an "initial" message with the current info. Would it be more efficient to create a receiver object every so often, receive this initial message, then destroy it every time I want to check it? Or, is there a different way that I haven't thought about?</p>

<p>Sources that I used for monitoring the battery, in case if anybody is interested:</p>

<ul>
<li><a href="http://developer.android.com/training/monitoring-device-state/battery-monitoring.html" rel="nofollow">http://developer.android.com/training/monitoring-device-state/battery-monitoring.html</a></li>
<li><a href="http://developer.android.com/reference/android/os/BatteryManager.html" rel="nofollow">http://developer.android.com/reference/android/os/BatteryManager.html</a></li>
<li><a href="http://stackoverflow.com/questions/1805895/android-battery-in-sdk">Android Battery in SDK</a></li>
</ul>
