I'm just wondering if is there any possibility to obtain battery status in broadcast receiver class that fires on ACTION_POWER_CONNECTED? Documentation suggest not, but it is always worth to ask :)
Cheers Ray
I'm just wondering if is there any possibility to obtain battery status in broadcast receiver class that fires on ACTION_POWER_CONNECTED? Documentation suggest not, but it is always worth to ask :)
Cheers Ray
Call
registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED))
. TheIntent
that is returned is the last-broadcastACTION_BATTERY_CHANGED
broadcast, which has your battery status in its extras (seeBatteryManager
for the keys).If you determine that you are calling it too soon, that
ACTION_POWER_CONNECTED
is invoked beforeACTION_BATTERY_CHANGED
gets updated, perhaps useAlarmManager
to schedule yourself to wake up again in a few seconds, and check again then.