3 Replies Latest reply on Aug 4, 2017 4:10 AM by Darryn Campbell

    Find the Screen Width for Zebra Device in general

    ankit agrawal

      For our product, we report is device a tablet or mobile based on screen width to the concern website. Now for TC700H it is reporting has tablet, though it is a mobile device.


      Attaching a snapshot from the website for understanding.


      TC 700H

      {density=2.0, width=720, height=1280, scaledDensity=2.0, xdpi=160.421, ydpi=160.157}


      And as per our cal the value of screen width is coming above 9 inches. Which in reality TC700H is not.


      Following code we are using for cal

      public String getScreenWidth()


        WindowManager winMgr = (WindowManager) context.getSystemService(Application.WINDOW_SERVICE);

         if (winMgr != null)

        Display display = winMgr.getDefaultDisplay();


        DisplayMetrics displayMetrics = new DisplayMetrics();

         if (display != null) {




         else {




         float xdpi = displayMetrics.xdpi;


         int pixels = displayMetrics.widthPixels;

        Maas360Logger.d(loggerName, "Width pixels :" + pixels);

         float width = pixels / xdpi;


         float height = displayMetrics.heightPixels / displayMetrics.ydpi;


         double size = Math.hypot(height, width);


        BigDecimal bd = BigDecimal.valueOf(size);

        bd = bd.setScale(1, BigDecimal.ROUND_HALF_UP); // round to 1
         // decimal
         return bd.toString();


         else {

        Maas360Logger.e(loggerName, "Error querying screen resolution, display is null ");



         else {

        Maas360Logger.e(loggerName, "Error collecting screen resolution, cannot query windows manager");


         return null;


      Is there any other way we can get Screen width for Zebra Devices?

        • Re: Find the Screen Width for Zebra Device in general
          Darryn Campbell

          That 9" value you have calculated is for the diagonal, not the width as you are using Math.hypot (which I didn't realise existed until I looked it up for this question!)


          Regardless, obviously the TC70 does not have a 9" screen diagonal.  The width and height are greater than I would expect by about 2x compared to a real device, your width is coming out at 4.49" (720/160.421) and your height is coming out at 7.99" (1280/160.157).  Coincidentally the screen density is 2x.


          Your device IS going down the getRealMetrics path presumably?  In which case, perhaps it is an issue with the device not taking the screen density into account.  According to the Android docs getRealMetrics should be the real size of the display.  If your code is going down the getMetrics path then you need to take screen density into account.  I do not have a device to test with unfortunately.