# Changing battery level

**URL:** <https://discuss.appium.io/t/changing-battery-level/8660>\
**Category:** Support\
**Created:** [February 21, 2016, 11:42am UTC](https://discuss.appium.io/t/changing-battery-level/8660 "2016-02-21T11:42:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![vicidroid](https://discuss.appium.io/letter_avatar_proxy/v4/letter/v/f9ae1b/32.png) [@vicidroid](https://discuss.appium.io/u/vicidroid)\
**Post date:** [February 21, 2016, 11:42am UTC](https://discuss.appium.io/t/changing-battery-level/8660/1 "2016-02-21T11:42:39Z")

</div>

I want to test application when battery is low. Is it possible to change battery level using Appium?

---

<div class="post-metadata">

**Author:** ![willosser](https://discuss.appium.io/user_avatar/discuss.appium.io/willosser/32/2454_2.png) [@willosser](https://discuss.appium.io/u/willosser)\
**Post date:** [February 22, 2016, 4:51pm UTC](https://discuss.appium.io/t/changing-battery-level/8660/2 "2016-02-22T16:51:01Z")

</div>

If you are running your test case locally, you can call adb. The following two commands can be used to change the battery level and update the rest of the system:

adb shell am broadcast -a android.intent.action.BATTERY\_CHANGED --ei status 3 --ei level \<desired\_level\> --ei scale 100  
adb shell am broadcast -a android.intent.action.BATTERY\_LOW

---

<div class="post-metadata">

**Author:** ![vicidroid](https://discuss.appium.io/letter_avatar_proxy/v4/letter/v/f9ae1b/32.png) [@vicidroid](https://discuss.appium.io/u/vicidroid)\
**Post date:** [February 23, 2016, 7:52pm UTC](https://discuss.appium.io/t/changing-battery-level/8660/3 "2016-02-23T19:52:06Z")

</div>

Thanks for your reply.

Is there a method to do this inside my test class on Eclipse or can we use just command prompt for this purpose?

---

<div class="post-metadata">

**Author:** ![willosser](https://discuss.appium.io/user_avatar/discuss.appium.io/willosser/32/2454_2.png) [@willosser](https://discuss.appium.io/u/willosser)\
**Post date:** [February 24, 2016, 5:14pm UTC](https://discuss.appium.io/t/changing-battery-level/8660/4 "2016-02-24T17:14:19Z")

</div>

As far as I know, this is not built into Appium. You will need to either explore appium-adb or make a system call from your test code.

---

<div class="post-metadata">

**Author:** ![Moshik177](https://discuss.appium.io/letter_avatar_proxy/v4/letter/m/e8c25b/32.png) [@Moshik177](https://discuss.appium.io/u/Moshik177)\
**Post date:** [October 9, 2017, 8:04am UTC](https://discuss.appium.io/t/changing-battery-level/8660/5 "2017-10-09T08:04:00Z")

</div>

Hi ,  
i have a question on this issue , i need to change the battery charging state to discharging in the Intent.ACTION\_BATTERY\_CHANGE ( i need to run a test , that the phone is not charge but i use usb that charge the phone) , i try to use adb commands like "“adb shell am broadcast -a android.intent.action.BATTERY\_CHANGED --ez present false --ei state 3 --ei level 40 --ei plugged 0” or “adb shell dumpsys battery set status 3 | set usb 0” but the intent isn’t change , can appium help with that or there is another way to handle this issue?

---

<div class="post-metadata">

**Author:** ![willosser](https://discuss.appium.io/user_avatar/discuss.appium.io/willosser/32/2454_2.png) [@willosser](https://discuss.appium.io/u/willosser)\
**Post date:** [October 31, 2017, 3:47pm UTC](https://discuss.appium.io/t/changing-battery-level/8660/6 "2017-10-31T15:47:35Z")

</div>

It may be due to the version of Android you are using. I’ve stopped working with Android recently, but I recall we were having problems with Android N or maybe O because of Android changes. As far as I know, Appium has nothing here to help you.
