Skip to content

Commit

Permalink
fixes crashes in android 11 or lower devices
Browse files Browse the repository at this point in the history
  • Loading branch information
Ishan09811 authored Feb 24, 2024
1 parent 4a49684 commit ee9441f
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ protected void onResume() {
InputHandler.setMotionDeadZone(InputMap.getDeadZone());
InputHandler.setEventListener(inputListener);
if (GlobalConfig.get(GlobalConfig.KEY_PICTURE_IN_PICTURE)) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
setPictureInPictureParams(new PictureInPictureParams.Builder().setAutoEnterEnabled(true).build());
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
getTheme().applyStyle(R.style.GameActivityNavigationBar, true);
Expand Down Expand Up @@ -112,13 +114,15 @@ public void onUserLeaveHint() {
// Calculate aspect ratio
float aspectRatio = (float) widthPixels / (float) heightPixels;

if (GlobalConfig.get(GlobalConfig.KEY_PICTURE_IN_PICTURE)) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
Rational aspectRatioRational = new Rational(widthPixels, heightPixels);
PictureInPictureParams.Builder pipBuilder = new PictureInPictureParams.Builder();
pipBuilder.setAspectRatio(aspectRatioRational);
enterPictureInPictureMode(pipBuilder.build());
}
}
}

@Override
protected void onPause() {
Expand Down

0 comments on commit ee9441f

Please sign in to comment.