Reputation: 12656
What's the difference between:
<uses-permission android:name="some_permission" />
and
<activity android:permission="some_permission" />
My application uses the former but not the latter and still works. Why would I use the latter? Specifically, why does it work without the latter?
Thanks in advance...
Upvotes: 1
Views: 981
Reputation: 12147
In summary,
<uses-permission android:name="some_permission" />
is something your app should hold to perform some user data sensitive or dangerous operation.
<activity android:permission="some_permission" />
is something other apps or other component in your app should hold in order to start your activity.
Upvotes: 1
Reputation: 21766
Although it is clear from the structure and tags itself i.e. uses-permission
means this permission will be used by the app and android:permission
inside activity tag means permission required to start that activity.
Below is difference between uses-permission
and android:permission
from official documentation.
android:permission
(Activity permission enforcement)
Permissions applied using the android:permission attribute to the tag in the manifest restrict who can start that Activity. The permission is checked during Context.startActivity() and Activity.startActivityForResult(). If the caller doesn't have the required permission then SecurityException is thrown from the call.
Link: https://developer.android.com/guide/topics/permissions/overview.html#permission_enforcement
uses-permission
Specifies a system permission that the user must grant in order for the app to operate correctly. Permissions are granted by the user when the application is installed (on devices running Android 5.1 and lower) or while the app is running (on devices running Android 6.0 and higher).
Link : https://developer.android.com/guide/topics/manifest/uses-permission-element.html
Now come to your question:
My application uses the former but not the latter and still works. Why would I use the latter? Specifically, why does it work without the latter?
Answer: as from above explanation it is clear that latter is required if you want some other app to access your that activity i.e. that permission is not required by your app or activity But other apps to start that activity. So your app will work perfectly fine without latter one i.e. android:permission
Hope it make sense.
Upvotes: 4
Reputation: 1791
<uses-permission>
is when your application is seeking the user's permission to use some feature
Ex:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18" />
<permission>
is when your application is requiring other apps to seek the user's permission to use some feature of yours.
Ex:
<permission android:description="string resource" android:icon="drawable resource" android:label="string resource" android:name="string" android:permissionGroup="string" android:protectionLevel=["normal" | "dangerous" | "signature" | ...] />
You can read : https://developer.android.com/guide/topics/manifest/permission-element.html
Upvotes: 1