Im trying to check – if app has an permission or not, but recive negative result independently of real state of permission – turn it on or off via adb – same result from checkSelfPermission.
My code to check:
private fun checkInstallPermission(): Boolean {
return ContextCompat.checkSelfPermission(this, Manifest.permission.REQUEST_INSTALL_PACKAGES) == PackageManager.PERMISSION_GRANTED
}
so this is always negative, rather if im do adb shell appops … permission allow
My manifest:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
Target API: 31
Min API: 30
Im tried to access permissions directly or via package name – same result.
Expecting that this method will be true
in case of permission requested and granted.
Super Hero is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.