In this article, I will show you how to create an Android app that shows Battery Level.
Introduction
In this article, I will show you how to create an Android app that shows the Battery Level of your device. A battery is an electrochemical cell (or enclosed and protected material) that can be charged electrically to provide a static potential for power or released electrical charge when needed.
Requirements
Steps to be followed
Follow these steps to create the app using Android Studio. I have attached the source code too.
Step 1 Open Android Studio and start a new Android Studio Project.
Step 2
You can choose your application name and choose where your project is stored. If you wish to use C++ for coding the project, mark the "Include C++ support", and click "Next" button.
Step 3
Now, select the version of Android and select the target Android devices. We need to choose the SDK level which plays an important role to run the application.
Step 4
Now, add the activity and click "Next" button.
Step 5
Add Activity name and click "Finish".
Step 6
Go to activity_main.xml. This XML file contains the designing code for the Android app. The XML code is given below.
Step 7
Go to Main Activity.java. This Java program is the back-end language of Android. The java code is given below.
Step 8
Go to (App ⇒ Res ⇒Layout⇒progressbar_states.xml). The Progressbar_states.xml code is given below.
Step 9
Now, go to menu bar and click "Make project" or press ctrl+f9 to debug the error.
Step 10
Then, click Run button or press shift+f10 to run the project. And, choose the virtual machine option and click OK.
Conclusion
We have successfully created the app that shows the battery level of our Android phone.
Pro WPF: Windows Presentation Foundation in .NET 3.0