title: Retrieve Outgoing number from broadcast Reciever android
body: <p>I am trying to create customized screen for outgoing calls. For which I would like to get outgoing number.</p>
  
  <p>I was looking at this link which uses a separate broadreceiver for incoming and outgoing. </p>
  
  <p><a href="http://goo.gl/YUD1b5" rel="nofollow">http://goo.gl/YUD1b5</a></p>
  
  <p>But doesn't work. I get error message upon making a call</p>
  
  <pre><code>java.lang.NullPointerException: println needs a message
  </code></pre>
  
  <p>I have one broadcast receiver which has manifest:</p>
  
  <pre><code>     &lt;receiver
          android:name="com.honey.ringer.PhoneListenerBroad"
          android:priority="999"
          android:enabled="true" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.NEW_OUTGOING_CALL" /&gt;
              &lt;action android:name="android.intent.action.PHONE_STATE" /&gt;
          &lt;/intent-filter&gt;
      &lt;/receiver&gt;
  </code></pre>
  
  <p>The broadcast receiver is called when ever I call out but I am not able to retrieve the out going call phone number. I am not sure what to do here:</p>
  
  <p>Here is the broadcast receiver file:</p>
  
  <pre><code>public void onReceive(Context context, Intent intent) 
   {
      c = context;
  
      try
      {
          TelephonyManager tmgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
          MyPhoneStateListener PhoneListener = new MyPhoneStateListener();
          tmgr.listen(PhoneListener, PhoneStateListener.LISTEN_CALL_STATE);
      }
      catch (Exception e) 
      {
          Log.e("Phone Receive Error", " " + e);
      }
  
  }
  
  private class MyPhoneStateListener extends PhoneStateListener
  {
      public void onCallStateChanged(final int state, final String incomingNumber) 
      {
          Handler callActionHandler = new Handler();
  
          Runnable runRingingActivity = new Runnable() 
          {
              @Override
              public void run() 
              {
                  Intent intentPhoneCall = new Intent(c, AcceptMakeCall.class);
                  intentPhoneCall.putExtra("incomingnumber", incomingNumber);
                  intentPhoneCall.putExtra("state", state);
                  intentPhoneCall.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                  c.startActivity(intentPhoneCall);
              }
          };
  
          if (state == 1)
          {
              callActionHandler.postDelayed(runRingingActivity, 100);
          }
  
          if (state == 0) 
          {
              callActionHandler.removeCallbacks(runRingingActivity);
          }
  
          if (state == 2)
          {
              /*callActionHandler.postDelayed(runRingingActivity, 100);*/
  
  
          }
      }
  }
  </code></pre>
  
  <p>Can somebody help me to get the outgoing number?</p>