title: Android Calculate Remaining time of battery and subsytems.
body: <p>I wanted to calculate the remaining hours of battery and subsystem as talk time, websurfing, audio playback, video playback and standby.</p>
  
  <p>I used reflection to get private class <strong>com.android.internal.os.PowerProfile</strong> and <strong>android.os.BatteryStats</strong>.</p>
  
  <p>I followed Android's battery setting 
  <a href="http://netmite.com/android/mydroid/donut/packages/apps/Settings/src/com/android/settings/fuelgauge/PowerUsageSummary.java" rel="nofollow">http://netmite.com/android/mydroid/donut/packages/apps/Settings/src/com/android/settings/fuelgauge/PowerUsageSummary.java</a> </p>
  
  <p>to get remaining hours of battery </p>
  
  <p>with method:</p>
  
  <pre><code>long computeBatteryRealtime(long curTime, int which);
  </code></pre>
  
  <p>with:</p>
  
  <pre><code>curTime = SystemClock.elapsedRealtime() * 1000;
  which = STATS_UNPLUGGED
  </code></pre>
  
  <p>But the return value was wrong, a few minutes. Do I use this method right ?</p>