Outgoing calls

RimesRimes USMember
edited August 2014 in Xamarin.Android


i am trying to get the events when a call has ended (no matter if incomming or outgoing). Since there is not an event for that i have to trick a little bit (ExtraStateOffhook + ExtraStateidle = call ended)

So far i have implemented the Broadcastrecevier, and when i am being called i get the number which is calling me (so far so good).

But now i am trying to get the number when i am calling (so i am performing an outgoing call), and there my object stays empty.

Here is my code where i get the number for the incomming call:

[IntentFilter(new[] { "android.intent.action.PHONE_STATE" })]
class PhoneCallStateBroadcast : BroadcastReceiver
    static string OldCallState = "";
    public override void OnReceive(Context context, Intent intent)
        Log.Debug("MeinDebug", "got event");

        if (intent.Extras == null)

        string state = intent.GetStringExtra(TelephonyManager.ExtraState);

        // call ended
        if ((OldCallState == TelephonyManager.ExtraStateOffhook ) && (state == TelephonyManager.ExtraStateIdle))
            string PhoneNumer = intent.Extras(TelephonyManager.ExtraIncomingNumber);

            Toast.MakeText(context, PhoneNumer, ToastLength.Long);

        OldCallState = state;


I have also tried implementig the Phonelistener and overriding "OnCallStateChanged" but there i event dont get the number when i am being called (at least i get the right state). On the permissions i have set these two : READ_PHONE_STATE and PROCESS_OUTGOING_CALLS

Has anybody done something like this, or at least has an idea ?

And what i forgot, is it possible to get call details for the last call (for example the duration)? Or do i have to take care of this on my own ?

kind regards


  • on button click a call should be made and when call is hung up the control should go back to app(i.e. after the call is hung up my dashboard screen should be visible).. can anybody tell me how to implement this in xamarin..

    Below is my code

    PhoneCallListener mPhoneListener = new PhoneCallListener(this, this);
    mPhoneListener.yourActivity = true;
    TelephonyManager tm = (TelephonyManager)GetSystemService(TelephonyService);
    tm.Listen(mPhoneListener, PhoneStateListenerFlags.CallState);
    var uri = Android.Net.Uri.Parse("tel:1112223333");
    var intent = new Intent(Intent.ActionDial, uri);

    private class PhoneCallListener : PhoneStateListener
    private bool isPhoneCalling = false;
    public bool yourActivity = false;
    Context c = null;
    private readonly DashBoardActivity dashboardactivity;
    public PhoneCallListener(Context c,DashBoardActivity activity)
    this.c = c;
    this.dashboardactivity = activity;
    public void onCallStateChanged(CallState state, String incomingNumber)
    base.OnCallStateChanged(state, incomingNumber);
    switch (state)

                    case CallState.Idle:
                        var intent = new Intent(dashboardactivity, typeof(DashBoardActivity));
                        Console.Out.WriteLine("Back To activity");

    my oncallStateChanged is not getting called.. plz someone help me...

Sign In or Register to comment.