How to get screen display metrics in application class
Solution 1:
Here, Context.getResource()
DisplayMetrics dm = getResources().getDisplayMetrics();
int densityDpi = dm.densityDpi;
Solution 2:
You can also try this:
WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
final DisplayMetrics displayMetrics = new DisplayMetrics();
wm.getDefaultDisplay().getMetrics(displayMetrics);
int height = displayMetrics.heightPixels;
int width = displayMetrics.widthPixels;
Solution 3:
Try this:
Display display = getWindowManager().getDefaultDisplay();
Log.e("", "" + display.getHeight() + " " + display.getWidth());