androidandroid-picture-in-picture

How to know if user has disabled Picture in Picture feature permission?


enter image description here

and here is another example:

enter image description here

from the screenshot above we see user is able to disable picture in picture mode. you can find it in the "special app access" screen on the emulator api 27 . How can i detect if user has disabled this feature ?

i tried checking the following but it does not work:

packageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE)

compiler states that AppOpsManager cannot be found. any ideas ?


Solution

  • Try AppOpsManager.checkOp (String op, int uid, String packageName), where op is OPSTR_PICTURE_IN_PICTURE operation. That method should return MODE_ALLOWED constant if supports Picture in Picture operation.

    For more info, check this link.