mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-04-21 07:50:11 +00:00
Use onPictureInPictureRequested() to enter PiP on Android 11
This commit is contained in:
@@ -633,8 +633,8 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
super.onUserLeaveHint();
|
super.onUserLeaveHint();
|
||||||
|
|
||||||
// PiP is only supported on Oreo and later, and we don't need to manually enter PiP on
|
// PiP is only supported on Oreo and later, and we don't need to manually enter PiP on
|
||||||
// Android S and later.
|
// Android S and later. On Android R, we will use onPictureInPictureRequested() instead.
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
|
||||||
if (autoEnterPip) {
|
if (autoEnterPip) {
|
||||||
try {
|
try {
|
||||||
// This has thrown all sorts of weird exceptions on Samsung devices
|
// This has thrown all sorts of weird exceptions on Samsung devices
|
||||||
@@ -648,6 +648,16 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@TargetApi(Build.VERSION_CODES.R)
|
||||||
|
public boolean onPictureInPictureRequested() {
|
||||||
|
// Enter PiP when requested unless we're on Android 12 which supports auto-enter.
|
||||||
|
if (autoEnterPip && Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
|
||||||
|
enterPictureInPictureMode(getPictureInPictureParams(false));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWindowFocusChanged(boolean hasFocus) {
|
public void onWindowFocusChanged(boolean hasFocus) {
|
||||||
super.onWindowFocusChanged(hasFocus);
|
super.onWindowFocusChanged(hasFocus);
|
||||||
|
|||||||
Reference in New Issue
Block a user