title: Unable to detect incoming call number using BroadcastReceiver [ Marshmallow]
body: <p>I am trying to log the phone number whenever I get an incoming call using <code>BroadcastReceiver</code> . However, I do not get any <code>log</code> when I dial to my number. This is the code:</p>
  
  <p><strong>AndroidManifest.xml</strong></p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.abc.broadcast_phone" &gt;
  
      &lt;uses-permission android:name="android.permission.READ_PHONE_STATE"/&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:supportsRtl="true"
          android:theme="@style/AppTheme" &gt;
  
          &lt;receiver android:name=".MyPhoneReceiver" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.PHONE_STATE" &gt;
                  &lt;/action&gt;
              &lt;/intent-filter&gt;
          &lt;/receiver&gt;
          &lt;activity android:name=".MainActivity" &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;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>    public class MainActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          Intent intent = new Intent("tuet");
          sendBroadcast(intent);
      }
  }
  </code></pre>
  
  <p><strong>MyPhoneReceiver.java</strong></p>
  
  <pre><code>    public class MyPhoneReceiver extends BroadcastReceiver
  {
      @Override
      public void onReceive(Context context, Intent intent) {
          Bundle extras = intent.getExtras();
          if (extras != null)
          {
              String state = extras.getString(TelephonyManager.EXTRA_STATE);
  
              if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
                  String phoneNumber = extras
                          .getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
                  Log.e("DEBUG", phoneNumber);
              }
          }
      }
  }
  </code></pre>
  
  <p>I am compiling using SDK 23 and target is also Marshmallow, should I be using run time permission in this case? Or am I missing something? </p>
  
  <p><strong>EDIT-1</strong></p>
  
  <p>Seems like the problem is only associated with Marshmallow onwards, when I downgraded the target sdk version, this is working fine : <code>targetSdkVersion 22</code> .</p>
  
  <p>So, how to tweak this to work in SDK23+ onwards?</p>