Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test battery charging speed?

How can I detect battery charging speed in android device? I can detect battery status using below code. but not charging speed.

IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_BATTERY_CHANGED);
BatteryChangeReceiver receiver = new BatteryChangeReceiver(subscriber);
registerReceiver(receiver, filter);


public class BatteryChangeReceiver extends BroadcastReceiver {

    @Override public void onReceive(Context context, Intent intent) {
              // here I get all battery status.
    }
  }

I also refer this,this and this but cant find the way to check charging speed.

There is an app (Ampere) that displaying charging speed. enter image description here enter image description here How can I achieve this?

Thanks in advance.

like image 539
Kishan Vaghela Avatar asked Aug 12 '16 07:08

Kishan Vaghela


People also ask

How do I know if my battery is fast charging?

Check Your Phone's Spec Sheet Head over to the brand's site, select your phone and check the specifications section. Here, you can see the charging technology and power output (18W, 30W, 65W, and so on- the larger the number, the faster the charging). Most brands also mention the charger specifications.

How do I test a charging port with a multimeter?

Plug the USB multimeter into your port. The multimeter requires no external power, so as you plug it into the port it automatically turns on. You can see the results on your screen, it is just that simple. Voltage is measured in Volts (V), so you the results ending with V i.e 5V or something like it.

What is the normal speed of charging?

The average smartphone receives about 2.5W to 6W while charging from its USB port. Fast chargers raise that amount about 10 times, with some phones heading towards 120W! You should note that not all phones support fast charging and that all chargers aren't fast chargers.


1 Answers

Use the BatteryManager. It provides the property BATTERY_PROPERTY_CURRENT_AVERAGE, which gives you the average battery current in microamperes. Unfortunately, the time period over which this information is collected may differ from device to device. Negative values mean discharging, positive values mean the phone is charging.

Alternatively, you could use BATTERY_PROPERTY_CURRENT_NOW (it looks like Ampere is using this approach). It returns the instantaneous battery current. It may not be accurate, so calling this property a couple times and calculating the average seems like a good idea.

Example code:

BatteryManager batteryManager = (BatteryManager) Context.getSystemService(Context.BATTERY_SERVICE);
int averageCurrent = batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CURRENT_AVERAGE);
like image 100
Manuel Allenspach Avatar answered Sep 25 '22 12:09

Manuel Allenspach