使用 xamarin.forms.android 检测屏幕镜像 [英] Detect screen mirroring using xamarin.forms.android

查看:23
本文介绍了使用 xamarin.forms.android 检测屏幕镜像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检测安卓屏幕镜像到电脑.我目前正在使用 c# Xamarin Forms Android 进行编码.

我做了什么

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.

解决方案

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
}

这篇关于使用 xamarin.forms.android 检测屏幕镜像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆