diff options
| -rw-r--r-- | core/java/android/app/Activity.java | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index af5fafbc93d4..87fc8fe392f0 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -2838,7 +2838,13 @@ public class Activity extends ContextThemeWrapper throw new IllegalStateException("Activity must be resumed to enter" + " picture-in-picture"); } - return ActivityTaskManager.getService().enterPictureInPictureMode(mToken, params); + // Set mIsInPictureInPictureMode earlier and don't wait for + // onPictureInPictureModeChanged callback here. This is to ensure that + // isInPictureInPictureMode returns true in the following onPause callback. + // See https://developer.android.com/guide/topics/ui/picture-in-picture for guidance. + mIsInPictureInPictureMode = ActivityTaskManager.getService().enterPictureInPictureMode( + mToken, params); + return mIsInPictureInPictureMode; } catch (RemoteException e) { return false; } |