Android:检测 ADB 何时通过 USB 激活

标签 android adb

是否可以让应用程序检测 ADB 何时通过 Android 手机上的 USB 进行监听?

我正在寻找这样的东西:Is it possible to determine whether an Android device is plugged into a computer or just power?但特别适用于 ADB 运行时。

谢谢!

最佳答案

Settings.Global.getInt(context.getContentResolver(), Settings.Global.ADB_ENABLED, 0);

如果手机上启用了 USB 调试,则返回 1,否则返回 0。

关于Android:检测 ADB 何时通过 USB 激活,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16741787/

相关文章:

android - 带有 BaseAdapter 的 Android ListView 中的 ImageButton

ANDROID PLACE_PICKER (builder.build(context)

android - Chrome ADB 扩展不适用于 Debian 7

android - 在 Galaxy Tab 10.1 上调试应用程序

android - 我们可以在 iOS 设备上无线运行 Flutter 应用吗?

android - 如何通过亚行解锁安卓手机

android - 使用 Google Places API 在 Google map 中查找附近的地点

java - TCPDump-Buffer 上的 ReadLine 有时会阻塞,直到终止 tcpdump

java - Android - 如何管理具有不同内容的单个 fragment 的多个实例?

android - Android 应用程序可以将自身复制到 Root设备上的系统目录吗?