On Wed, Mar 9, 2011 at 2:29 PM, Greg Donald <gdon...@gmail.com> wrote:
> I can't get my BroadcastReceiver to work.  I'm not getting any errors
> so I'm not sure what the issue is.
>
> My class looks like this:
>
> public class CallReceiver extends BroadcastReceiver
> {
>  @Override
>  public void onReceive( final Context context, final Intent intent )
>  {
>    Log.i( "l", "onReceive()" );
>    Log.i( "l", "context: " + context );
>    Log.i( "l", "intent: " + intent );
>
>    if( intent.getAction().equals( Intent.ACTION_NEW_OUTGOING_CALL ) )
>    {
>      String number = intent.getExtras().getString( Intent.EXTRA_PHONE_NUMBER 
> );
>      Log.i( "l", "number: " + number );
>    }
>  }
> }
>
> I am using the "statically publish" method.  I have an entry like this
> between my <application> tags in my manifest:
>
> <receiver android:enabled="true"
> android:name="com.example.shared.CallReceiver"></receiver>
>
> I have the READ_PHONE_STATE permission in my manifest:
>
> <uses-permission
> android:name="android.permission.READ_PHONE_STATE"></uses-permission>
>
> To test it I am simply placing an out going call.  The problem is I
> never see any of the log messages I am expecting to see.  What am I
> missing or doing wrong?

Since we last spoke, I found I needed to add an intent-filter:

<intent-filter>
  <action 
android:name="android.intent.action.ACTION_NEW_OUTGOING_CALL"></action>
</intent-filter>

But the number is still coming up null when I do this:

String number = intent.getExtras().getString( Intent.EXTRA_PHONE_NUMBER );
Log.i( "l", "number: " + number );

How can I get the outgoing phone number?


Thanks,

-- 
Greg Donald
destiney.com | gregdonald.com

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to