Skip to content

Instantly share code, notes, and snippets.

@SurajBahadur
Created December 5, 2022 06:42
Show Gist options
  • Save SurajBahadur/29e93e52ed46a91e6be458632f0ebda4 to your computer and use it in GitHub Desktop.
Save SurajBahadur/29e93e52ed46a91e6be458632f0ebda4 to your computer and use it in GitHub Desktop.
Check whether PIP is enable Or disable for the app in android
startActivity(Intent("android.settings.PICTURE_IN_PICTURE_SETTINGS", Uri.parse("package:${packageName}")))
/**
* Check whether pip is enable or not
* @return true is enable and vice versa
*/
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
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment