簡體   English   中英

與設備連接時確定是否啟用USB調試

[英]Determine usb debugging enabled or not when connected with device

嗨,我正在使用xamarin android,我試圖確定使用我的應用程序時,當我的應用程序連接了設備USB調試功能時,我試圖使用以下代碼,但找不到

Settings.Secure

我想使用下面的代碼

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

如果我是對的,請問我如何在我的項目中使用它?

在API 17中已棄用Settings.Secure.AdbEnabledSettings.System.AdbEnabled並將其移到Global

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

參考: ADB_EN​​ABLED

注意:這不能確定調試橋是否處於活動狀態。

如果您正在尋找附加調試器的時間,則可以使用:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM