Android - 故意快速耗尽电池电量
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24941062/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android - Drain battery quickly on purpose
提问by arleitiss
I am nearly finished with my app and last functionality to be made is to call specific action when battery level reaches below specific level.
我几乎完成了我的应用程序,最后一个功能是在电池电量低于特定水平时调用特定操作。
So for test purposes I am wondering - how can I drain battery?
因此,出于测试目的,我想知道 - 如何耗尽电池电量?
P.S - Using AVD wont work since my app is using Google Play services so I am testing app on my phone.
PS - 使用 AVD 不起作用,因为我的应用程序正在使用 Google Play 服务,所以我正在我的手机上测试应用程序。
回答by Gilad Haimov
For fastest drain turn on at once all battery drainers:
为了尽快打开所有电池排水器:
- Acquire a Wake lock with Full screen brightness (No. 1 battery drainer)
- Vibration
- GPS with zero time polling intervals
- Turn on WiFi and continuously issue http requests
- Turn on Bluetooth and continuously issue scan commands
- 获得全屏亮度唤醒锁(耗电第一)
- 振动
- 具有零时间轮询间隔的 GPS
- 开启WiFi并不断发出http请求
- 打开蓝牙并不断发出扫描命令
And, since you're a smart guy, you will probably use this appinstead of hand-coding all of the above.
而且,由于您是一个聪明人,您可能会使用此应用程序而不是手动编写上述所有内容。
回答by vmagro
There is an AVD target that contains Play Services (Google APIs target).
有一个包含 Play 服务(Google API 目标)的 AVD 目标。
Edit: you should also be able to use Genymotionfrom what I've read. It's also much faster than the stock emulator, but if your app uses any native code it may not work.
编辑:您还应该能够从我读过的内容中使用Genymotion。它也比股票模拟器快得多,但如果您的应用程序使用任何本机代码,它可能无法正常工作。