Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
324 views
in Technique[技术] by (71.8m points)

uses-permission vs permission for android permissions in the manifest.xml file

I noticed that there are two types of permissions in the manifest file, "permission" and "uses-permission" like the two shown below;

 <permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />

 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

for the following 4 permissions which do I use when I put them in my manifest.xml file? uses-permissions or permissions?

android.permission.ACCESS_NETWORK_STATE

android.permission.ACCESS_WIFI_STATE

android.permission.INTERNET

android.permission.CHANGE_WIFI_MULTICAST_STATE
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

For

<permission>

The documentation states:

Declares a security permission that can be used to limit access to specific components or features of this or other applications.

Therefore, since you are accessing Android's permissions, you want uses-permission instead. The documentation for this element states:

Requests a permission that the application must be granted in order for it to operate correctly.

<permission> is normally used when making a custom permission (e.g. when making an app that other apps can tie in to, limiting access is a must), and <uses-permission> is used when your app actually needs a permission it doesn't have normally.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...