Reputation: 152
In the main Activity, I asked the User for permissions for using Camera. However, I wanted to use the Camera in another activity let's SecondaryActivity I asked for permissions like this in one activity :-
if(ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.CAMERA)
!= PackageManager.PERMISSION_GRANTED){
ActivityCompat.requestPermissions(this, PERMISSIONS_REQUIRED, 1);
}
and checking in other activity just before starting the service.
if(ContextCompat.checkSelfPermission(SecondaryActivity.this, Manifest.permission.CAMERA)
== PackageManager.PERMISSION_GRANTED) { // Do Something }
Since, both this
here are different, will I have to request permissions for different activities differently or not ?
Upvotes: 0
Views: 48
Reputation: 6014
Permissions are granted or revoked for the whole application, not a specific activity.
However, it is still best practice to always check if you have a permission, right before you need it. Users can grant and revoke permissions at runtime. Allthough revoking a permission will lead to a restart of your activity.
Upvotes: 1