batterylevel - Android :How to get Battery status without Broadcast Receiver for API level 17 and above? -
i want battery status. searched on stack , found sample code using broadcast receiver problem in code cannot use broadcast receiver.
so there way battery status without using broadcast receiver. possible api 21 , above want api 17 , above. thank you
intent battery=registerreceiver(null, new intentfilter(intent.action_battery_changed)); battery contain last-broadcast action_battery_changed intent, , extras contain battery information, using keys documented on batterymanager.
(this code work inside method of context subclass; alternatively, call registerreceiver() on other context)
Comments
Post a Comment