Reputation: 921
On Android >= 6:
When a method, that requires a permission P, is invoked but the permission P isn't declared in the manifest a java.lang.SecurityException
will be raised.
The same exception occurs when I doesn't check if a dangerous permission was granted and I invoke a method that uses it.
When you ask for a dangerous permission P at runtime with the ActivityCompat.requestPermissions
method, but the dangerous permission P isn't declared in the manifest, the dialog box doesn't appear and the permission is denied by default (and you can't see that this happened looking the logs).
Are those claims right?
Upvotes: 0
Views: 43
Reputation: 1006724
When a method, that requires a permission P, is invoked but the permission P isn't declared in the manifest a java.lang.SecurityException will be raised.
Correct in general. There may be some fringe cases where some other exception gets raised. The behavior secured by the permission will not work normally.
The same exception occurs when I doesn't check if a dangerous permission was granted and I invoke a method that uses it.
Only on Android 6.0+, for apps with targetSdkVersion
23 or higher.
When you ask for a dangerous permission P at runtime with the ActivityCompat.requestPermissions method, but the dangerous permission P isn't declared in the manifest, the dialog box doesn't appear and the permission is denied by default (and you can't see that this happened looking the logs).
The "denied by default" part is identical to your first question. Otherwise, you are correct — you can only request runtime permissions for those dangerous
ones that you requested in the manifest.
Upvotes: 1