How to simulate low battery in Android devices

With the Android Emulator's Extended Controls, it's now possible to set the battery level with a GUI slider called "Charge Level."

To access this, start the emulator. Then click the "..." at the bottom of the settings panel (which hovers to the right of the emulator).

enter image description here

This opens the Extended Controls panel which contains a "Battery" menu item:

enter image description here

The Charge Level slider goes from 0 to 100%. You can also simulate failed/overheated/etc physical battery, and being off the charger by adjusting the other drop down controls.


Is the battery removable? If so, get a spare battery and keep it in a low charge state for your low battery testing.


simulating low battery is not provided by default as far as i know.(if you are using eclipse as im). But if you are in linux , u can use telnet to connect to ur localhost emulator and perform 'Power' actions.(not used them maybe u can give a try) http://handycodeworks.com/?p=46

But u dont have to go through that process. Just register a broadcast receiver for ACTION_BATTERY_LOW, and it is guaranteed to be called in low battery scenarios.

Hope it helps

EDIT:

here is the direct answer (assuming that ur running windows).

Enable 'telnet' on windows if you havent already.

Control panel-->programs-->under 'programs and features' select 'turn windows features on or off'-->it opens a new window select 'telenet client' and click on OK.

start command prompt with admin rights(in AllPrograms search for 'cmd' and right click on it and select run as admin).

then use this commands

1)telnet localhost 5554 //where 5554 is your emulator id, which is displayed top left   corner of ur emulator
2)power capacity 10   //set the battery level to 10%
3)power ac off    //turns off charging mode

Now you can see a low battery dialog in emulator.


Use the following commands

To simulate the device being unplugged:

adb shell dumpsys battery unplug

To test how the device behaves under low power conditions:

adb shell settings put global low_power 1

Once you have finished your testing, you can undo your manual device settings with this command:

adb shell dumpsys battery reset

Tags:

Android