how best can I build an application that opens when it recievs a call i have tried broadcastReacieve

mambomambo Member ✭✭

here is my code

[BroadcastReceiver(Enabled =true, Exported =true)]
[IntentFilter(new[] { TelephonyManager.ActionPhoneStateChanged })]
public class Reciever : BroadcastReceiver
{
public override void OnReceive(Context context, Intent intent)
{
Toast.MakeText(context, "Received intent!", ToastLength.Short).Show();
if(intent.Action == TelephonyManager.ActionPhoneStateChanged)
{
var state = intent.GetStringExtra(TelephonyManager.ExtraState);
if(state == TelephonyManager.ExtraStateRinging)
{
var number = intent.GetStringExtra(TelephonyManager.ExtraIncomingNumber);
Toast.MakeText(context, number, ToastLength.Short).Show();
}
}
}
}

Tagged:
Sign In or Register to comment.