How to check the remaining battery level of your controller

We use a sticky intent similar to the android intent.action.BATTERY_CHANGED intent which apps can use to get updates regarding the compute pack battery level and status. Documentation on using the system intent can be found here: Monitor the Battery Level and Charging State | Android Developers

The controller battery intent is named com.magicleap.controller.action.BATTERY_CHANGED. The extras attached to the intent will follow what the system battery intent uses, so that code that processes the system battery intent can be used as the basis for code to process the controller battery intent. The following extras are populated in the controller battery intent:

  • If the connection to the controller is active, the following extras will be set:
    • BatteryManager.EXTRA_PRESENT : true
    • BatteryManager.EXTRA_LEVEL : current controller battery level (0-100)
    • BatteryManager.EXTRA_SCALE : 100
    • BatteryManager.EXTRA_BATTERY_LOW : true if current level is 25% or lower, otherwise false
    • BatteryManager.EXTRA_STATUS : BatteryManager.BATTERY_STATUS_CHARGING or BatteryManager.BATTERY_STATUS_NOT_CHARGING, based on controller charger connection state
  • If the connection to the controller is not active, the following extras will be set:
    • BatteryManager.EXTRA_PRESENT : false
    • BatteryManager.EXTRA_STATUS : BatteryManager.BATTERY_STATUS_UNKNOWN