1

SOLVED: Sry but I am an idiot. I forgot to make this import: import android.Manifest

I just want to check if the user has given the permission for making phone calls.

if (ContextCompat.checkSelfPermission(this, 
   Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED){
}

Android Studio says that it can not resolve this CALL_PHONE symbol.

This is my AndroidManifest file:

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

Can anybody help me?

EDIT:

My main problem is that I can`t read any permission at all.

  • Are you importing the correct Manifest class? https://developer.android.com/reference/android/Manifest.permission.html – OneCricketeer Oct 01 '16 at 15:03
  • 1
    Since you cannot hold `CALL_PRIVILEGED`, and since the user cannot grant it to you, you have bigger problems. `CALL_PRIVILEGED` has a `protectionLevel` of `signature`. The only way an app can hold it is if the app is signed by the same signing key that signed the firmware, which means the app is part of some custom ROM. The user cannot grant you this permission. The user *can* grant you `CALL_PHONE`, and that is what you have in your manifest. Change your Java to refer to `CALL_PHONE`. – CommonsWare Oct 01 '16 at 15:10
  • Please explain, in detail, what "I can't read any permission at all" means. Do you have an `import` statement for `Manifest.permission`? – CommonsWare Oct 01 '16 at 15:23
  • @CommonsWare yes this was my problem thx =) –  Oct 01 '16 at 15:27
  • Write your solution as answer it might help someone else. – Dominique Lorre Oct 01 '16 at 15:28

2 Answers2

1

You need to use:

Manifest.permission.CALL_PHONE

EDIT:

Check this post about CALL_PRIVILEGED

Ok the permission exists but someone in this thread states that:

This permission has the signatureOrSystem protection level, which is why it does not work, unless a user on a rooted phone makes the app a system app.

Community
  • 1
  • 1
Dominique Lorre
  • 1,168
  • 1
  • 10
  • 19
1

To be able to use Manifest.permission constants, you need to import android.Manifest, as Manifest is a Java class.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491