如何从通过USB编程停止充电手机 [英] How to stop the phone from charging via USB programmatically
问题描述
我已经尝试做尽可能多的研究,可能的,但无法找到一个答案,这个很简单的问题(想算出这个之前,我要建立SDK和一切).I'm思考关于发展我的第一个应用程序,并想知道是否 BATTERY_STATUS_CHARGING
从 BatteryManager
仅包含一个 GET
函数或还设置
的功能。
I've tried to do as much research as possible but can't find an answer to this fairly simple question (want to figure this out before I'm going to set up the SDK and everything).I'm thinking about developing my first app and am wondering whether the BATTERY_STATUS_CHARGING
from the BatteryManager
contains only a get
function or also a set
function.
我wan't使一个应用程序中,我可以手动停止充电的手机,而不从充电器(通过USB)拔掉它,所以我想知道这是否实际上是可能的。
I wan't to make an app in which I can manually stop the phone from charging without unplugging it from the charger (via USB) and so am wondering whether this is actually possible.
推荐答案
没有,它不可能在无根设备。它使用 Settings.System
与 ADB_ENABLED
,而 ADB_ENABLED
是一个安全-系统设置不能由一个应用程序来改变。
No, Its not possible on unrooted devices. It uses Settings.System
with ADB_ENABLED
, but ADB_ENABLED
is a Secure-System-Setting which can not be changed by a application.
是的,它可以在扎根电话完成的。
Yes, It can be done on rooted phone.
有需要添加一个权限 android.permission.WRITE_SECURE_SETTINGS。
同类型的在谷歌Play应用程序的:<一href="https://play.google.com/store/apps/details?id=com.jim2&hl=en">https://play.google.com/store/apps/details?id=com.jim2&hl=en
Same type of application on Google Play : https://play.google.com/store/apps/details?id=com.jim2&hl=en
这篇关于如何从通过USB编程停止充电手机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!