在 manifest.xml 文件中使用权限与 android 权限的权限 [英] uses-permission vs permission for android permissions in the manifest.xml file

查看:26
本文介绍了在 manifest.xml 文件中使用权限与 android 权限的权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到清单文件中有两种类型的权限,permission"和uses-permission",如下图所示;

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" />

对于以下 4 个权限,当我将它们放入我的 manifest.xml 文件时,我会使用它们吗?uses-permissions 还是 permissions?

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

推荐答案

对于

<permission>

文档 指出:

声明一个安全权限,可用于限制对该应用程序或其他应用程序的特定组件或功能的访问.

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

因此,由于您正在访问 Android 的权限,您需要 uses-permission 代替.此元素的文档说明:

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> 用于当您的应用程序实际上需要它通常没有的权限时.

<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.

这篇关于在 manifest.xml 文件中使用权限与 android 权限的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆