Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect external displays in android prior API 17

I'm working in app that has copyrighted videos that should work only in Android device and not in external display connected via HDMI or wirelessly. I found great API Presentation and DisplayManager to detect and control which content to be displayed on external displays but this API's available only in API 17 (android 4.2) and plus. Any idea in how to do this below android 4.2 or at least to detect and be notified for connected displays.

Question #2: What about if android device is connected to PC for screen recording. Can Presentation or DisplayManager API help to detect that?

like image 923
Hossam Ghareeb Avatar asked Sep 10 '15 10:09

Hossam Ghareeb


1 Answers

Going back to API 16 you can use MediaRouter class. Cf android developer website.

To get the default display for your presentation, call MediaRouter.getSelectedRoute() and pass it ROUTE_TYPE_LIVE_VIDEO. This returns a MediaRouter.RouteInfo object that describes the system’s currently selected route for video presentations. If the MediaRouter.RouteInfo is not null, call getPresentationDisplay() to get the Display representing the connected display.

Full source: http://developer.android.com/about/versions/android-4.2.html#SecondaryDisplays

like image 191
Distwo Avatar answered Sep 30 '22 19:09

Distwo