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

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -