I am trying to get a list of running applications and the number of batteries used by each of them. I have google for a long time, but have not come up with a solution. However, there were several references to the internal PowerProfile, PowerUsageSummary classes.
I used them in the Reflection technique, but did not get what I was looking for. PowerUsageSummary shows the same details that you can see by going to the device settings-> Applications-> Battery usage (this can be seen on the Samsund device).
Then I used the PowerProfile class, but only got the mA of current used by WIFI, AUDIO, VIDEO, GPS, BLUETOOTH, etc. (The mA values ββdo not change so often. I'm not sure that the values ββare correct). Another reference was the BatteryStatsImpl class. I tested this class, but the values ββare always 0. However, I am looking for a list of running applications and the number of batteries used by each of them. Any help is appreciated.
Thank,
Here is an example of the code I tried for the BatteryStatsImpl class.
String BATTERY_PROFILE_CLASS = "com.android.internal.os.BatteryStatsImpl";
Object mBatteryProfile = Class.forName(BATTERY_PROFILE_CLASS).getConstructor().newInstance();
Method batteryMeth = Class.forName(BATTERY_PROFILE_CLASS).getMethod("getBatteryUptime", long.class);
Object arglist1[] = new Object[1];
arglist1[0] = System.currentTimeMillis();
Long batteryUptime = (Long) batteryMeth.invoke(mBatteryProfile, arglist1);
Method dischargeMeth = Class.forName(BATTERY_PROFILE_CLASS).getMethod("getDischargeStartLevel");
Integer dischargeTime = (Integer) dischargeMeth.invoke(mBatteryProfile);
source
share