File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
VideoOS/VenvyLibrary/src/main/java/cn/com/venvy/common/utils Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -655,8 +655,14 @@ public static int getScreenWidth(@Nullable Context context) {
655655 }
656656
657657 public static int getScreenPPI (@ Nullable Context context ) {
658- DisplayMetrics dm = new DisplayMetrics ();
659- return dm .densityDpi ;
658+ WindowManager windowManager = (WindowManager )context .getSystemService (Context .WINDOW_SERVICE );
659+ DisplayMetrics displayMetrics = new DisplayMetrics ();
660+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .JELLY_BEAN_MR1 ) {
661+ windowManager .getDefaultDisplay ().getRealMetrics (displayMetrics );
662+ }else {
663+ windowManager .getDefaultDisplay ().getMetrics (displayMetrics );
664+ }
665+ return displayMetrics .densityDpi ;
660666 }
661667
662668 /**
You can’t perform that action at this time.
0 commit comments