简体   繁体   English

使用 xamarin.forms.android 检测屏幕镜像

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

I want to detect android screen mirroring to pc.我想检测到 pc 的android 屏幕镜像 I am currently coding in c# Xamarin Forms Android .我目前正在使用c# Xamarin Forms Android 进行编码。

What I have done我做了什么

Here someone recommended to use DisplayManager and VirtualDisplay documentation.这里有人推荐使用DisplayManagerVirtualDisplay文档。 But I don't know how to achieve that in code.但我不知道如何在代码中实现这一点。

Here someone recommended to check DisplayManager.getDisplays(), and see if it's >1. 这里有人建议检查DisplayManager.getDisplays(),看看它是否>1。 Again not working to detect vysor I tried with code.再次无法检测我尝试使用代码的 vysor。

It is not possible to do so in Android.在 Android 中这是不可能的。

Reference 参考

The closest you could get is by using FlagSecure to prevent screenshots.您可以获得的最接近的是使用FlagSecure来防止屏幕截图。

Finally I got the working answer.最后我得到了有效的答案。
Android mirrors like vysor can't mirror without having developer options enabled.像 vysor 这样的 Android 镜像在没有启用开发者选项的情况下无法镜像。
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
}

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将KML文件路由添加到Xamarin.Forms.Android谷歌地图? - How to add KML-file routes to a Xamarin.Forms.Android google map? Xamarin.Forms.Android:在编译/部署时使用示例数据文件填充“Environment.SpecialFolder.Personal” - Xamarin.Forms.Android: Populating 'Environment.SpecialFolder.Personal' with sample data files at compilation/deployment 如何检测在Android设备上启用的屏幕镜像 - How to detect screen mirroring enabled on android device Xamarin.Forms.Android:java.lang.IllegalStateException:片段没有视图 - Xamarin.Forms.Android: java.lang.IllegalStateException: Fragment does not have a view 使用团队演示共享手机屏幕时,如何检测 android 中的屏幕镜像? - How to detect screen mirroring in android when my mobile screen is shared using teams presentation? 如何检测屏幕镜像 - how to detect screen mirroring 在android中的屏幕镜像 - screen mirroring in android 如何在Xamarin.Forms中获取/检测屏幕大小? - How to get/detect screen size in Xamarin.Forms? 禁用 iOS/Android 屏幕镜像 - Disable iOS/Android screen mirroring android投屏时如何锁屏? - How to lock android screen during screen mirroring?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM