How to set battery status of Android Emulator using the Emulator Console

In last two exercise "Detect Battery Level" and "Detect Battery Info", the apps about battery checking have been built. We have to set the battery status on Android Emulator to check our apps. To change the battery status on Android Emulator, Emulator Console can be used.

To connect to the console of any running emulator instance at any time, use this command:

telnet localhost <console-port>

Where <console-port> is the number shown on your emulator.

Details of the usage, refer to the section Using the Emulator Console of the document Android Emulator.