簡體   English   中英

使用 xamarin.forms.android 檢測屏幕鏡像

[英]Detect screen mirroring using xamarin.forms.android

我想檢測到 pc 的android 屏幕鏡像 我目前正在使用c# Xamarin Forms Android 進行編碼。

我做了什么

這里有人推薦使用DisplayManagerVirtualDisplay文檔。 但我不知道如何在代碼中實現這一點。

這里有人建議檢查DisplayManager.getDisplays(),看看它是否>1。 再次無法檢測我嘗試使用代碼的 vysor。

在 Android 中這是不可能的。

參考

您可以獲得的最接近的是使用FlagSecure來防止屏幕截圖。

最后我得到了有效的答案。
像 vysor 這樣的 Android 鏡像在沒有啟用開發者選項的情況下無法鏡像。
要檢查鏡像是否可以運行,請檢查以下代碼:

//https://stackoverflow.com/a/31582092/11390822

var context = Android.App.Application.Context;
var resolver = context.ApplicationContext.ContentResolver;
if (Settings.Secure.GetInt(resolver, Settings.Global.DevelopmentSettingsEnabled, 0) == 1)
{
//Developer options enabled
//Mean vysor can mirror
}
else
{
//Developer options disabled
//Mean vysor can't mirror now
}

在此處輸入圖片說明

暫無
暫無

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

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