Created
December 5, 2022 06:42
-
-
Save SurajBahadur/29e93e52ed46a91e6be458632f0ebda4 to your computer and use it in GitHub Desktop.
Check whether PIP is enable Or disable for the app in android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
startActivity(Intent("android.settings.PICTURE_IN_PICTURE_SETTINGS", Uri.parse("package:${packageName}"))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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