使用以下命令
模拟设备被拔出:
adb shell dumpsys battery unplug
Run Code Online (Sandbox Code Playgroud)
要测试设备在低功耗条件下的行为:
adb shell settings put global low_power 1
Run Code Online (Sandbox Code Playgroud)
完成测试后,您可以使用以下命令撤消手动设备设置:
adb shell dumpsys battery reset
Run Code Online (Sandbox Code Playgroud)
据我所知,默认情况下不提供模拟低电量的电池(如果你使用eclipse作为im).但是如果你在Linux中,你可以使用telnet连接到你的localhost模拟器并执行'Power'动作.(不用它们也许你可以尝试一下) http://handycodeworks.com/?p=46
但你不必经历这个过程.只需为ACTION_BATTERY_LOW注册广播接收器,即可在低电量情况下调用它.
希望能帮助到你
编辑:
这是直接答案(假设您正在运行Windows).
如果你还没有在Windows上启用'telnet'.
控制面板 - >程序 - >在"程序和功能"下选择"打开或关闭打开窗口功能" - >打开一个新窗口选择"远程客户端"并单击"确定".
使用管理员权限启动命令提示符(在AllPrograms中搜索'cmd'并右键单击它并选择以管理员身份运行).
然后使用此命令
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
Run Code Online (Sandbox Code Playgroud)
现在,您可以在模拟器中看到电量不足的对话框.
| 归档时间: |
|
| 查看次数: |
6345 次 |
| 最近记录: |