Created
July 3, 2015 13:34
-
-
Save letz/3756e5e97015f54aa84c to your computer and use it in GitHub Desktop.
Check if android device is tablet or smartphone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DisplayMetrics metrics = new DisplayMetrics(); | |
getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics); | |
float yInches= metrics.heightPixels/metrics.ydpi; | |
float xInches= metrics.widthPixels/metrics.xdpi; | |
double diagonalInches = Math.sqrt(xInches*xInches + yInches*yInches); | |
if (diagonalInches>=6.5){ | |
// 6.5inch device or bigger | |
}else{ | |
// smaller device | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment