Thursday, 18 April 2019

Secondary display DisplayMetrics dependent on primary display?

I have two different tablets:

  • 10.1" tablet - 1280x800 @ ~149dpi
  • 15.6" tablet - 1920x1080 @ ~156dpi

These tablets are both very close to 160dpi (where 1px is equivalent to 1dp) in terms of actual physical (real-world) specifications. The system reports them as being exactly 160dpi. That's fine, no big deal here.

I also have a secondary display. It has the same physical (real-world) specifications as my 10.1" tablet. However, when I connect it to the two different tablets and use it to display an Android Presentation, the secondary display will report wildly different DisplayMetrics.

When connected to the 10.1" tablet, the secondary display reports:

  • Resolution: 1280x800
  • DPI: 237.0
  • Density: 1.48125

When connected to the 15.6" tablet, the secondary display reports:

  • Resolution: 1024x768
  • DPI: 227.0
  • Density: 1.41875

What could cause this?


The app itself is dumb as rocks. All I do is create a Presentation object and show a dummy checkerboard layout on both the primary and secondary displays.

I've tried using both the MediaRouter and DisplayManager APIs for finding my Display and creating my Presentation. They both give identical results.

@Override
protected void onResume() {
    super.onResume();

    MediaRouter mediaRouter = (MediaRouter) getSystemService(Context.MEDIA_ROUTER_SERVICE);
    MediaRouter.RouteInfo route = mediaRouter.getSelectedRoute(MediaRouter.ROUTE_TYPE_LIVE_VIDEO);

    if (route != null) {
        Display display = route.getPresentationDisplay();
        if (display != null) {
            Presentation presentation = new MyPresentation(this, display);
            presentation.show();
        }
    }
}

@Override
protected void onResume() {
    super.onResume();

    DisplayManager manager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
    Display[] displays = manager.getDisplays(DisplayManager.DISPLAY_CATEGORY_PRESENTATION);

    if (displays.length > 0) {
        Presentation presentation = new MyPresentation(this, displays[0]);
        presentation.show();
    }
}



from Secondary display DisplayMetrics dependent on primary display?

No comments:

Post a Comment