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?


Any idea in how to do this below android 4.2 or at least to detect and be notified for connected displays.

Beyond possibly MediaRouter in API Level 16 as noted in Distwo's answer, there was no support for app-level access to external displays in older versions of Android. Relatively few devices even supported external displays; those that did only offered OS-level screen mirroring.

Your best bet, if you want to call it that, is to get your hands on a few such devices and see if there are any common LogCat messages that indicate the existence of external displays, or maybe some Linux-level stuff in /proc . However, there is a very good chance that these will wind up being different by manufacturer and device.

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

No.


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

链接地址: http://www.djcxy.com/p/28848.html

上一篇: howto:弹性beanstalk +部署docker +优雅关机

下一篇: 如何检测android之前的API 17中的外部显示