从应用程序内以编程方式启用 USB 调试(在设置/应用程序/开发下) [英] Enable USB debugging (under settings/applications/development) programmatically from within an app

查看:23
本文介绍了从应用程序内以编程方式启用 USB 调试(在设置/应用程序/开发下)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在我的应用程序中以编程方式启用 USB 调试(在设置/应用程序/开发下)?

Is it possible to enable USB debugging (under settings/applications/development) programmatically from within my app?

我正在查看 Permission.WRITE_SETTINGShttp://developer.android.com/reference/android/provider/Settings.System.html,但我找不到合适的.

I was looking at Permission.WRITE_SETTINGS and http://developer.android.com/reference/android/provider/Settings.System.html, but I couldn't find anything appropriate.

推荐答案

您需要根权限才能从应用程序执行此操作.

也就是说,可以通过执行以下终端命令来启用 ADB:

That said, it is possible to enable ADB by executing the following terminal commands:

setprop persist.service.adb.enable 1
start adbd

这篇博文 给出了一个很好的例子,说明如何通过 su 以升级的权限执行这些命令.

This blog post gives an excellent example of how to execute these commands with escalated permissions through su.

这篇关于从应用程序内以编程方式启用 USB 调试(在设置/应用程序/开发下)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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