YorkShen commented on a change in pull request #2536: [Android] fix Android9 
inaccurate ScreenHeight problem
URL: https://github.com/apache/incubator-weex/pull/2536#discussion_r292827157
 
 

 ##########
 File path: android/sdk/src/main/java/com/taobao/weex/utils/WXViewUtils.java
 ##########
 @@ -207,7 +210,14 @@ public static int getScreenHeight() {
   public static int getScreenHeight(Context cxt) {
     if(cxt!=null){
       Resources res = cxt.getResources();
-      mScreenHeight =cxt.getResources().getDisplayMetrics().heightPixels;
+      if(Build.VERSION.SDK_INT >= 28){
+        Point size = new Point();
+        
((WindowManager)cxt.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getRealSize(size);
 
 Review comment:
   
`((WindowManager)cxt.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay()`
 may be null, add an `if` case or `try catch` when something unexpected happens 
then return the old-style screenHeight 
`cxt.getResources().getDisplayMetrics().heightPixels;` as before.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to