简体   繁体   English

如何检测屏幕镜像

[英]how to detect screen mirroring

I have been wondering if there is any way in the android API (or any other lib/framework) that can help me to detect if my device screen is mirrored using WiDi,Miracast or MHL or basically any other technique for mirroring your screen.我一直想知道在 android API(或任何其他库/框架)中是否有任何方法可以帮助我检测我的设备屏幕是否使用 WiDi、Miracast 或 MHL 或基本上任何其他用于镜像屏幕的技术进行镜像。

Br, Inx溴,英克斯

You may navigate through the list of all device display and get flags on each for finding one with, maybe, VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR ?您可以浏览所有设备显示的列表并获取每个设备显示的标志,以便找到带有 VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR 的设备? Not sure but a few trys should allow you to figure out which ones will do it.不确定,但尝试几次应该可以让您弄清楚哪些可以做到。

cf: DisplayManager and VirtualDisplay documentation cf: DisplayManagerVirtualDisplay文档

You can't detect but you can remove functionality which mirrors.您无法检测,但可以删除镜像的功能
No software can mirror if developer option is disabled .如果禁用开发者选项,则任何软件都无法镜像。
This code will tell whether android can mirror or not.此代码将告诉 android 是否可以镜像。

int CanMirror = Settings.Secure.getInt(this.getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED , 0);
//returns 1 if can mirror
//returns 0 if can't mirror

Reference : https://stackoverflow.com/a/63971764/11390822参考: https : //stackoverflow.com/a/63971764/11390822

Since API level 16 (Android 4.1, released in 2012 so rather new when the question was asked) Android has had MediaRouter API.自 API 级别 16(Android 4.1,于 2012 年发布,所以在提出问题时相当新)Android 已经有了MediaRouter API。 Adding callback for ROUTE_TYPE_LIVE_VIDEO subscribes MediaRouter.Callback.onRoutePresentationDisplayChanged to be called when external display is connected or disconnected.ROUTE_TYPE_LIVE_VIDEO添加回调订阅MediaRouter.Callback.onRoutePresentationDisplayChanged以在外部显示器连接或断开连接时调用。 If the app has sound, other option is to track routed output.如果应用程序有声音,另一个选项是跟踪路由输出。 The output types TYPE_HDMI and TYPE_REMOTE_SUBMIX are used for external display.输出类型TYPE_HDMITYPE_REMOTE_SUBMIX用于外部显示。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM