Java tutorial
//package com.java2s; //License from project: Open Source License import android.app.Activity; import android.util.DisplayMetrics; public class Main { private static double getDisplayInches(Activity activity) { DisplayMetrics metrics = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(metrics); int widthPixels = metrics.widthPixels; int heightPixels = metrics.heightPixels; float widthDpi = metrics.xdpi; float heightDpi = metrics.ydpi; float widthInches = widthPixels / widthDpi; float heightInches = heightPixels / heightDpi; double diagonalInches = Math.sqrt((widthInches * widthInches) + (heightInches * heightInches)); return diagonalInches; } }