taejun
taejun

Reputation: 23

Launch Settings about picture-in-picture mode in android

i am korean student so i am sorry about not good at English..

is there any way to launch "Android Setting -> Apps -> Special Access -> PIP" using intent??

I couldn't sleep a wink because of this.

Upvotes: 1

Views: 1066

Answers (2)

Suraj Bahadur
Suraj Bahadur

Reputation: 3928

I am late to this answer and want to add to open app-specific pip setting screen. You need to pass the package id of the app in the second parameter.

startActivity(Intent("android.settings.PICTURE_IN_PICTURE_SETTINGS", Uri.parse("package:${packageName}")))

Also, you can check whether PIP is enabled/disabled on the app by using the below method.

 private fun hasPipPermission(): Boolean {
        val appOps = getSystemService(APP_OPS_SERVICE) as AppOpsManager?
        return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
                appOps?.unsafeCheckOpNoThrow(AppOpsManager.OPSTR_PICTURE_IN_PICTURE, android.os.Process.myUid(), packageName) == AppOpsManager.MODE_ALLOWED
            } else {
                appOps?.checkOpNoThrow(AppOpsManager.OPSTR_PICTURE_IN_PICTURE, android.os.Process.myUid(), packageName) == AppOpsManager.MODE_ALLOWED
            }
        } else {
            false
        }
    }

Upvotes: 1

Brian Oh
Brian Oh

Reputation: 103

Normally you can launch settings you wish to use like this (in Kotlin)

startActivity(Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS))

Unfortunately, the constant for the picture-in-picture setting is hidden. This means that there are no ways to do the stuff reliably. I mean, reliably, there is no solution that works on every API version and every device. However, the following code snippet will work on some devices such as Android Emulator.

startActivity(Intent("android.settings.PICTURE_IN_PICTURE_SETTINGS"))

Upvotes: 1

Related Questions