如何从通过USB编程停止充电手机 [英] How to stop the phone from charging via USB programmatically

查看:635
本文介绍了如何从通过USB编程停止充电手机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试做尽可能多的研究,可能的,但无法找到一个答案,这个很简单的问题(想算出这个之前,我要建立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_EN​​ABLED ,而 ADB_EN​​ABLED 是一个安全-系统设置不能由一个应用程序来改变。

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆