简体   繁体   English

在Android Studio的AndroidManifest.xml中添加权限?

[英]Adding Permissions in AndroidManifest.xml in Android Studio?

In Eclipse we were able to add permissions in AndroidManifest.xml by going to AndroidManifest.xml->Permission-> Adding permissions. 在Eclipse中,我们可以通过转到AndroidManifest.xml-> Permission->添加权限在AndroidManifest.xml中添加权限。

How to add permissions in Android Studio? 如何在Android Studio中添加权限? How can we get a list of all the permissions that we can add to an Activity ? 我们如何获得可以添加到活动的所有权限的列表?

You can only type them manually, but the content assist helps you there, so it is pretty easy. 您只能手动输入,但内容辅助可以帮助您,因此非常简单。

Add this line 添加此行

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

and hit ctrl + space after the dot (or cmd + space on Mac). 点击后按ctrl + space (或Mac上的cmd +空格 )。 If you need an explanation for the permission, you can hit ctrl + q . 如果您需要有关权限的说明,可以按ctrl + q

You can type them manually but the editor will assist you. 您可以手动输入,但编辑器会帮助您。

http://developer.android.com/reference/android/Manifest.permission.html http://developer.android.com/reference/android/Manifest.permission.html

You can see the snap sot below. 你可以看到下面的快照。

在此输入图像描述

As soon as you type "a" inside the quotes you get a list of permissions and also hint to move caret up and down to select the same. 只要在引号内键入“a”,就会获得权限列表,并提示上下移动插入符号以选择相同的权限。

在此输入图像描述

Go to Android Manifest.xml and be sure to add the <uses-permission tag > inside the manifest tag but Outside of all other tags.. 转到Android Manifest.xml并确保在清单标记添加<uses-permission tag >所有其他标记之外添加..

<manifest xlmns:android...>

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

This is an example of the permission of using Internet. 这是使用Internet许可的示例。

You can add manually in the manifest file within manifest tag by: 您可以通过以下方式在清单标记内的清单文件中手动添加:

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

This permission is required to be able to access the camera device. 需要此权限才能访问相机设备。

It's quite simple. 这很简单。

All you need to do is: 你需要做的就是:

  • Right click above application tag and click on Generate 右键单击应用程序标记上方的,然后单击Generate
  • Click on XML tag 单击XML标记
  • Click on user-permission 单击用户权限
  • Enter the name of your permission. 输入您的权限名称。

Put these two line in your AndroidMainfest 将这两行放在AndroidMainfest中

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM