8

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.

Br, Inx

Inx
  • 2,364
  • 7
  • 38
  • 55

4 Answers4

0

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 ? Not sure but a few trys should allow you to figure out which ones will do it.

cf: DisplayManager and VirtualDisplay documentation

0

Since API level 16 (Android 4.1, released in 2012 so rather new when the question was asked) Android has had MediaRouter API. Adding callback for ROUTE_TYPE_LIVE_VIDEO subscribes MediaRouter.Callback.onRoutePresentationDisplayChanged to be called when external display is connected or disconnected. 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.

ojs
  • 285
  • 1
  • 13
-1

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.

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

Sorry IwontTell
  • 466
  • 10
  • 29
-2

I'm not sure what you are trying to achieve, but if you simply want to disable screenshots and such, you can use FLAG_SECURE.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Yuichi Araki
  • 3,438
  • 1
  • 19
  • 24