114

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,496
  • 1
  • 31
  • 46
Nilesh Agrawal
  • 3,002
  • 10
  • 26
  • 54
  • 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

138

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.

Axifive
  • 1,159
  • 2
  • 19
  • 31
vRallev
  • 4,982
  • 3
  • 31
  • 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
  • 132,755
  • 26
  • 225
  • 256
57

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.

Zar E Ahmer
  • 33,936
  • 20
  • 234
  • 300
8

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
  • 700
  • 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,542
  • 4
  • 36
  • 42
3

Put these two line in your AndroidMainfest

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
Farmer
  • 4,093
  • 3
  • 23
  • 47
Hossam Ali
  • 792
  • 4
  • 11