NAGARAJ K
NAGARAJ K

Reputation: 51

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

Upvotes: 2

Views: 1216

Answers (2)

Ultimo_m
Ultimo_m

Reputation: 4897

I would use this:

startActivityForResult(Intent("android.settings.PICTURE_IN_PICTURE_SETTINGS", Uri.parse("package:$packageName")), 0)

It will also scroll to and highlight your application

Upvotes: 0

Satyam Gupta
Satyam Gupta

Reputation: 464

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)

Upvotes: 0

Related Questions