androidkotlinpicture-in-pictureandroid-picture-in-picture

Is there any way to enable the PIP programatically


Am developing an app using PIP when the user turned off PIP in settings. I can check only the PIP is enable or not is there any way to enable pip Programatically


Solution

  • No, You can't as Android OS needs consent of user to enable PIP (Picture-in-Picture) . However you can show user a dialog box regarding activation of PIP and on action button open app's setting page from where he can manually enable PIP.

    Code to Open Setting Page :

    val intent = Intent(
    Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
    Uri.fromParts("package", packageName, null)
    )
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
    startActivity(intent)