简体   繁体   中英

Determine usb debugging enabled or not when connected with device

HI i am working with xamarin android i am trying to determine using my app that when my app connected with device USB debugging enabled or not i am trying to use below code but cannot find

Settings.Secure

I want to use below code

int adb = Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.ADB_ENABLED, 0);

Please if i am right how can i use it in my project if not then what's the other way

Settings.Secure.AdbEnabled and Settings.System.AdbEnabled were deprecated in API 17 and moved to Global

int adb = Settings.Global.GetInt(ContentResolver, Settings.Global.AdbEnabled, 0);

Ref: ADB_ENABLED

Note: This does not determine if the Debug Bridge is active or not.

If you are looking for when a debugger is attached you can use:

Log.Debug("SO", $"Java Debugger: {Android.OS.Debug.IsDebuggerConnected}");
Log.Debug("SO", $"Mono Debugger: {System.Diagnostics.Debugger.IsAttached}");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM