Skip to content

Commit

Permalink
Handle screen orientation exception
Browse files Browse the repository at this point in the history
  • Loading branch information
pranavpandey committed Jun 4, 2023
1 parent 0e4b3b1 commit edeb831
Showing 1 changed file with 6 additions and 1 deletion.
Expand Up @@ -364,10 +364,15 @@ public static int getScreenOrientation(@Nullable Context context) {
}

float scale = displayMatrix.density;
int rotation = display.getRotation();
int width = (int) (displayMatrix.widthPixels * scale + 0.5f);
int height = (int) (displayMatrix.heightPixels * scale + 0.5f);

int rotation = Surface.ROTATION_0;
try {
rotation = display.getRotation();
} catch (Exception ignored) {
}

if ((rotation == Surface.ROTATION_0
|| rotation == Surface.ROTATION_180) && height > width ||
(rotation == Surface.ROTATION_90
Expand Down

0 comments on commit edeb831

Please sign in to comment.