Battery Intent APIs

EMDK For Android 8.0

Overview

On Zebra devices, extra battery information is retrieved using the standard Android Battery Intent in the same way as with consumer devices (see below). On devices equipped with Zebra Power Precision or Power Precision Plus batteries, the following additional information can be retrieved:

  • Backup Battery Voltage
  • Battery Manufacture Date
  • Battery Serial Number
  • Part Number for Battery
  • Unique ID for Battery
  • Rated Capacity of the Battery
  • Charge Cycle count of the Battery

Enabling the Receiver


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

Processing The Data

The code below receives the Zebra-specific battery information provided by the Battery Intent extras. Notice that some values are strings and other values are integers.


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");  
        String uniqueid = intent.getExtras().getString("uniqueid");  
        int ratedcapacity = intent.getExtras().getInt("ratedcapacity");  
        int cycle = intent.getExtras().getInt("cycle");  
    }  
} 

Also See