and here is another example:
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 ?
PiP is a special type of multi-window mode mostly used for video playback. It lets the user watch a video in a small window pinned to a corner of the screen while navigating between apps or browsing content on the main screen.
just like AlexTa said. but i wanted to actually write the code to save someone some time:
private fun hasPermission(): Boolean {
val appOps = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
getSystemService(Context.APP_OPS_SERVICE) as AppOpsManager
} else {
return false
}
return appOps.checkOpNoThrow(AppOpsManager.OPSTR_PICTURE_IN_PICTURE, android.os.Process.myUid(), packageName) == AppOpsManager.MODE_ALLOWED
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With