danger.system
Class BatteryMonitor

java.lang.Object
  extended by danger.app.Listener
      extended by danger.system.BatteryMonitor


public class BatteryMonitor
extends Listener

Interface to the device's battery state.


Method Summary
static int getBatteryLevel()
          Get the approximate amount of battery life left.
static boolean isBatteryCharging()
          Whether the device is plugged into a charger, and actively charging.
static boolean isBatteryDischarging()
          Whether the device is unplugged and in a normal discharge cycle.
static boolean isBatteryFailingToCharge()
          Whether charging the battery failed.
static boolean isBatteryFull()
          Whether the device is plugged into a charger, but finished charging.
static boolean isBatteryLow()
          Whether the device is unplugged and running low on power.
static boolean isTrickleCharging()
          Returns true if the device can charge through USB, is currently connected via USB, but is not drawing current at the full rate.
 
Methods inherited from class danger.app.Listener
cancelEvents, childEventPump, childEventPumpDone, eventProblem, isDispatchingThread, receiveEvent, receiveEventInternal, sendEvent, sendEvent, sendEvent, sendEvent, sendEvent, sendLowPriorityEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isBatteryFailingToCharge

public static boolean isBatteryFailingToCharge()
Whether charging the battery failed.

Since:
4.0

isBatteryCharging

public static boolean isBatteryCharging()
Whether the device is plugged into a charger, and actively charging.


isBatteryFull

public static boolean isBatteryFull()
Whether the device is plugged into a charger, but finished charging.


isBatteryDischarging

public static boolean isBatteryDischarging()
Whether the device is unplugged and in a normal discharge cycle.


isTrickleCharging

public static boolean isTrickleCharging()
Returns true if the device can charge through USB, is currently connected via USB, but is not drawing current at the full rate.

Since:
4.0

isBatteryLow

public static boolean isBatteryLow()
Whether the device is unplugged and running low on power.


getBatteryLevel

public static int getBatteryLevel()
Get the approximate amount of battery life left. Note that the device's power consumption fluctuates wildly depending on what peripherals are active at any given time, resulting in often unpredictable drops in battery level. Protecting against this requires that the battery voltages be smoothed and latched, which can cause the reported level to be artificially low.

Returns:
level between 0-1000 accurate to about +/- 10%