title: Permission Denial With Broadcast Receiver
body: <p>I am trying to create an app which enters a log message when I make an outgoing call. </p>
  
  <p>However, when I run the code, I get a permission denial, despite the fact that I have entered in the permissions.</p>
  
  <p>Denial Log:</p>
  
  <p>"09-04 02:35:50.535    1294-1666/? W/BroadcastQueue﹕ Permission Denial: receiving Intent { act=android.intent.action.NEW_OUTGOING_CALL flg=0x10000010 (has extras) } to samples.varma.packagecom.testreceive2/.CallReceiver requires android.permission.PROCESS_OUTGOING_CALLS due to sender android (uid 1000)"</p>
  
  <p>Manifest Code:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="samples.varma.packagecom.testreceive2" &gt;
      android:versionCode="1"
      android:versionName="1.0"&gt;
  
      &lt;uses-sdk
          android:minSdkVersion="14"
          android:targetSdkVersion="23" /&gt;
  
  
      &lt;uses-permission android:name="android.permission.READ_PHONE_STATE"/&gt;
      &lt;uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"/&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &gt;
  
  
          &lt;activity
              android:name=".MainActivity"
              android:enabled="true"
              android:label="@string/app_name" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
  
  
          &lt;receiver
              android:name=".CallReceiver"&gt;
  
  
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.PHONE_STATE"/&gt;
                  &lt;action android:name="android.intent.action.NEW_OUTGOING_CALL"/&gt;
              &lt;/intent-filter&gt;
          &lt;/receiver&gt;
      &lt;/application&gt;
  
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>And here is the code for my receiver:</p>
  
  <pre><code>package samples.varma.packagecom.testreceive2;
  
  import android.content.BroadcastReceiver;
  import android.content.Context;
  import android.content.Intent;
  import android.telephony.TelephonyManager;
  import android.util.Log;
  
  public class CallReceiver extends BroadcastReceiver {
      public CallReceiver() {
      }
  
      @Override
      public void onReceive(Context context, Intent intent) {
          String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
          if (state == null) {
              String number = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
              Log.i("TAG", "Outgoing Number: " + number);
          } else if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
              String number = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
              Log.i("TAG", "Incoming Number: " + number);
          }
      }
          }
  </code></pre>
  
  <p>I am very new to this so there is a good chance that there are several errors or I am completely off base. Regardless I would greatly appreciate any guidance. Would anyone know why I am getting this denial?  </p>
  
  <p>Thanks</p>
  
  <p>Edit: </p>
  
  <p>It is also giving me these permission denials even though I have added the phone state permission.</p>
  
  <p>The privileged phone-state permission is a system permission so I cannot add.</p>
  
  <pre><code>09-04 04:36:03.249    1294-1440/? W/BroadcastQueue﹕ Permission Denial: receiving Intent { act=android.intent.action.PHONE_STATE flg=0x10 (has extras) } to samples.varma.packagecom.testreceive2/.CallReceiver requires android.permission.READ_PRIVILEGED_PHONE_STATE due to sender android (uid 1000)
  09-04 04:36:03.271    1294-1308/? W/BroadcastQueue﹕ Permission Denial: receiving Intent { act=android.intent.action.PHONE_STATE flg=0x10 (has extras) } to samples.varma.packagecom.testreceive2/.CallReceiver requires android.permission.READ_PHONE_STATE due to sender android (uid 1000)
  
   1294-1308/? W/BroadcastQueue﹕ Permission Denial: receiving Intent { act=android.intent.action.PHONE_STATE flg=0x10 (has extras) } to samples.varma.packagecom.testreceive2/.CallReceiver requires android.permission.READ_PHONE_STATE due to sender android (uid 1000)
  </code></pre>