Reputation: 31
I have a very simple question.
All I'm looking for is the code to find the PPI of an android screen, i know how to find the height and width in pixels but not the amount of pixels per inch. I need this to help me find the diagonal of the screen. I tried but it doesn't seem to work
DisplayMetrics displayMetrics = new DisplayMetrics();
WindowManager wm = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
int ppi = (int) displayMetrics.density;
Upvotes: 2
Views: 4740
Reputation: 1134
Maybe like this?
DisplayMetrics metrics = getResources().getDisplayMetrics();
See here
Upvotes: 2