7

I want to know if I can add permissions to the Manifest in Android Studio in the same way as in eclipse. What I mean is the permission tab that is generating for you automatically instead of putting it manually.

The Question here is if there is an option that makes it automatically instead of adding it manually!

The B
  • 515
  • 2
  • 5
  • 16

3 Answers3

6

Yes you can definitely do it manually. In fact, using the Studio is better for newbies since it avoids errors to certain extent!

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

Reference: Here

Community
  • 1
  • 1
Nishanthi Grashia
  • 9,645
  • 5
  • 41
  • 55
1

If you just type < in the usual place (below the manifest element at the top), you'll get a menu of options to choose from, including uses-permission. Select it, and Studio will put the whole element there, and show a menu of permissions from which to choose.

hBrent
  • 1,628
  • 1
  • 17
  • 36
0

This is the format for using the manifest permission manually Add your needed permission instead of MODIFY_PHONE_STATE

HERE IS THE CODE

int permissionCheck = ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.MODIFY_PHONE_STATE);

    if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
        Toast.makeText(MainActivity.this, "permissions denied", Toast.LENGTH_LONG).show();
        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.MODIFY_PHONE_STATE}, PERMISSIONS_REQUEST_CODE);
        Toast.makeText(MainActivity.this, "happen", Toast.LENGTH_LONG).show();
    } else {
        //TODO
        Toast.makeText(MainActivity.this, "permissions granted", Toast.LENGTH_LONG).show();
    }