Detect screen mirroring using xamarin.forms.android

本小妞迷上赌 提交于 2020-11-25 04:37:21

问题


I want to detect android screen mirroring to pc. I am currently coding in c# Xamarin Forms Android.

What I have done

Here someone recommended to use DisplayManager and VirtualDisplay documentation. But I don't know how to achieve that in code.

Here someone recommended to check DisplayManager.getDisplays(), and see if it's >1. Again not working to detect vysor I tried with code.


回答1:


It is not possible to do so in Android.

Reference

The closest you could get is by using FlagSecure to prevent screenshots.




回答2:


Finally I got the working answer.
Android mirrors like vysor can't mirror without having developer options enabled.
To check whether mirror can be run, check this code below:

//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
}



来源:https://stackoverflow.com/questions/63617411/detect-screen-mirroring-using-xamarin-forms-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!