I have this app on Android and I’m looking at trying to set it up to support Picture in Picture (pip) mode. In my AndroidManifest, I have "android:supportsPictureInPicture=true"
and the supporting code in the MainActivity to allow for pip. The change that I want to do is not have the setting within the application’s app setting on by default. I would like for this to be an opt-in feature vs and opt-out feature.
Was wondering if anyone’s attempted doing this or might have any insight or examples that would help with setting that toggle to be false
by default?
A lot of this has been purely academic, as I’ve been mainly researching this feature and how I’d incorporate it into the app. As for what my MainActivity looks like, it’s fairly simple with the following setup:
// Handled the settings for PictureInPicture Mode
if (supportsPictureInPicture)
{
// Other than just checking if the OS supports PiP, we'll need to check if the Device does as well
boolean isPipSupported = PackageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE);
if (isPipSupported)
{
Rational aspectRatio = new Rational(16, 9);
PictureInPictureParams pipParams = new PictureInPictureParams.Builder()
.setAutoEnterEnabled(true)
.setAspectRatio(aspectRatio)
.build();
setPictureInPictureParams(pipParams);
}
}
Jonathan Hall is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.