How to simulate low battery in Android devices

后端 未结 6 1978
独厮守ぢ
独厮守ぢ 2021-01-11 09:37

Can anyone tell me how can I simulate low battery in my rooted device?

I gone through this question but did not find much information on this.

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-11 10:05

    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.

提交回复
热议问题