113

In Eclipse we were able to add permissions in AndroidManifest.xml by going to AndroidManifest.xml->Permission-> Adding permissions.

How to add permissions in Android Studio? How can we get a list of all the permissions that we can add to an Activity ?

Melquiades
  • 8,316
  • 1
  • 27
  • 40
Nilesh Agrawal
  • 2,872
  • 9
  • 22
  • 51
  • http://developer.android.com/reference/android/Manifest.permission.html – TronicZomB Jun 05 '13 at 19:48
  • Help! None of the answers seem to work in current version 2.2.1. The manifest visible in the tree and editor is an empty placeholder with nothing but a comment. How do i edit the real thing? – gb96 May 07 '15 at 12:44

6 Answers6

137

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). If you need an explanation for the permission, you can hit ctrl + q.

vRallev
  • 4,594
  • 3
  • 27
  • 34
  • 14
    Where is the manifest file in the project tree in Android Studio? – djondal Apr 15 '15 at 00:03
  • 5
    Oh, just found it using the Android View in the project tree. – djondal Apr 15 '15 at 00:05
  • 2
    @djondal I used to find any file in Android studio by ctrl + shift + n this could be a better way to reach instead of straining your eyes. – Rohit Mandiwal Jul 26 '15 at 09:38
  • 2
    this must be one of those ways android studio is better than eclipse. – stu Jul 23 '16 at 15:47
  • 4
    Is there any particular context regarding *where* in the manifest file we add this, or can we just add it wherever? – Gnemlock Aug 23 '16 at 02:23
  • @djondal Expand **Projects Tab->Select Android->App->manifests** – Elshan Jun 14 '17 at 10:26
  • In Mac is ctrl + space as well. cmd + space actually launchs Spotlight from any application. However, to display "explanation" or, rather "Quick documentation look up", in Mac, press Ctrl + j instead of Ctrl + q. Check here if you want to see all keyboard shortcuts: https://developer.android.com/studio/intro/keyboard-shortcuts.html – Akronix Sep 29 '17 at 11:20
64

You can type them manually but the editor will assist you.

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

You can see the snap sot below.

enter image description here

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.

enter image description here

Raghunandan
  • 129,147
  • 24
  • 216
  • 249
52

Go to Android Manifest.xml and be sure to add the <uses-permission tag > inside the manifest tag but Outside of all other tags..

<manifest xlmns:android...>

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

This is an example of the permission of using Internet.

AndroidGeek
  • 30,803
  • 14
  • 212
  • 262
9

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.

Richa
  • 690
  • 8
  • 12
4

It's quite simple.

All you need to do is:

  • Right click above application tag and click on Generate
  • Click on XML tag
  • Click on user-permission
  • Enter the name of your permission.
Warren Sergent
  • 2,257
  • 3
  • 34
  • 38
3

Put these two line in your AndroidMainfest

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
Shailesh
  • 3,443
  • 3
  • 19
  • 42
Hossam Ali
  • 320
  • 1
  • 7