title: Calculating android screen size?
body: <p>Is it possible to calculate the android screen diagonal dimension in inches. </p>
  
  <p>I have tried below two approaches both is not suitable for my case.</p>
  
  <p>Approach 1:</p>
  
  <pre><code>DisplayMetrics displayMetrics = new DisplayMetrics();
  getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
  int absoluteHeightInPx = displayMetrics.heightPixels;
  int absoluteWidthInPx = displayMetrics.widthPixels;     
  double diagonalPixels = Math.sqrt((absoluteHeightInPx * absoluteHeightInPx) + (absoluteWidthInPx * absoluteWidthInPx));
  double diagonalInInches = diagonalPixels / displayMetrics.densityDpi;
  </code></pre>
  
  <p>Approach 2:</p>
  
  <pre><code>float actualHeight = absoluteHeightInPx * deviceDensity;
  float actualWidth = absoluteWidthInPx * deviceDensity;
  float deviceDensity = displayMetrics.density;
  float physicalPixelPerInchX = displayMetrics.xdpi;
  float physicalPixelPerInchY = displayMetrics.ydpi;
  float heightInInches = actualHeight / physicalPixelPerInchY;
  float widhtInInches = actualWidth / physicalPixelPerInchX;
  double diagonalInInches = Math.sqrt((heightInInches * heightInInches) + (widhtInInches * widhtInInches));
  </code></pre>
  
  <p>Could you correct if i am wrong. </p>
  
  <p>Thanks,
  Easwar</p>