How to check that USB debugging is enabled programmatically?

my question is on an Android phone, how can I check if the USB debugging flag is enabled or not programmatically? in my application I want to show USB debugging status and get it programmatically

How to get if usb debugging is enabled programmatically?

+6
source share
2 answers

Try the following:

if(Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.ADB_ENABLED, 0) == 1) { // debugging enabled } else { //;debugging does not enabled } 
+9
source

Plain:

  boolean isDebuggable = ( 0 != ( getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE )); 

And if you want to check if it is connected:

 if (!Debug.isDebuggerConnected()){ //Yes, it is. } 
0
source

Source: https://habr.com/ru/post/953557/


All Articles