Check/Get battery status in android source code

Check/Get battery status in android. hello, android developer today I will tell you how to get the battery percentage, charging status, battery technology, battery voltage, etc.please follow the code given below to Check/Get battery status in android source code.

  • First Create a new project in Android Studio
  • File ⇒ New Android ⇒ Application Project
  • Then Open src -> package -> MainActivity.java and then add following code :

JAVA (MainActivity.java)

  •  Now Open res -> layout -> activity_main.xml and then add following code :

XML (activity_main.xml)

Output:

Finally, run this project.

This is how Android application looks like.

battery status in android source code battery status in android source code

 

Leave a Reply

Your email address will not be published.