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

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -