Battery Intent API Reference

EMDK For Android 8.0

Overview

The purpose of this document is to describe the functionality of the Battery intent API interface. It is intended for Android developers with familiarity with the Android intent mechanisms.

Applies to Android 4.4 KitKat and later.

Also see Battery Intent API guide

On Zebra devices, extra battery information is retrieved using the standard Android Battery intent in the same was as with consumer devices. On devices equipped with Zebra Power Precision or Power Precision Plus batteries, the following extra information can be retrieved:

Battery Extras

# Data Definitions Constant name Data type Format Power Precision Power Precision Plus Backup Battery
1 Battery Manufacture Date mfd String yyyy-mm-dd X X
2 Part number for battery prefix is ’21-” or “82-” for example: 21-xxxxx-01 Rev. X partnumber String Prefix-5 or 6 #s-suffix revision X X
3 Battery serial number; matches the value on the physical battery label serialnumber String Alpha followed by 4 numbers X X
4 Backup battery voltage bkvoltage Int Units=mV X
5 Rated Capacity of the battery ratedcapacity Int Units=mAh X X
6 Decommission status of the battery battery_decommission Int 0=Battery good 1=Decommissioned Battery 2=Status Unknown X X
7 Cumulative charge using Zebra charging equipment only base_cumulative_charge Int Units=mAh X
8 Number of charge cycles battery_usage_numb Int X
9 Cumulative charge using ALL (Zebra or Non-Zebra) charging equipment total_cumulative_charge Int Units=mAh X X
10 Number of seconds passed since the battery was placed in a charger/terminal for the first time seconds_since_first_use Int Units=secs X
11 Maximum amount of charge that could be pulled from the battery under the present discharge conditions if the battery is fully charged present_capacity Int Units=mAh X
12 Battery health indicator in percentage (0 to 100) health_percentage Int Units=% X
13 Remaining time until the device becomes unusable under current discharge conditions. If the returned value is 65535, time_to_empty is unknown time_to_empty Int Units=mins X
14 Time until battery is fully charged under present charging conditions. If the returned value is 65535, time_to_empty is unknown time_to_full Int Units=mins X
15 Amount of usable charge remaining in the battery under current discharge conditions present_charge Int Units=mAh X

Programming Interface

Function Prototype


mIntent_Receiver = new Intent_Receiver();  
mIntentFilter = new IntentFilter();  
mIntentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);  
registerReceiver(mIntent_Receiver,mIntentFilter); 

Parameters

Please reference the Android Battery Manager API.

Return Values

In addition to the battery information Android returns by default, which can be found here, Zebra devices return the following additional parameters:

  • bkvoltage
  • mfd
  • serialnumber
  • partnumber
  • ratedcapacity
  • battery_decommission
  • battery_usage_numb   
  • health_percentage 
  • present_capacity 
  • base_cumulative_charge        
  • total_cumulative_charge       
  • present_charge      
  • time_to_empty        
  • time_to_full     
  • seconds_since_first_use      

Example


public void onReceive(Context context, Intent intent) {      
    if (BATTERY_STATE_CHANGED_INTENT.equals(intent.getAction())) {          

        int bkvoltage = intent.getExtras().getInt("bkvoltage");  
        String mfd = intent.getExtras().getString("mfd");  
        String serialnumber = intent.getExtras().getString("serialnumber");  
        String partnumber = intent.getExtras().getString("partnumber");   
        int ratedcapacity = intent.getExtras().getInt("ratedcapacity");  
        int cycle = intent.getExtras().getInt("cycle");  

    }  
}