I want to detect the outgoing call when it is answered, I use a BroadcastReciever with the following code:
class OutgoingReceiver : BroadcastReceiver
{
public override void OnReceive(Context context, Intent intent)
{
string number = intent.GetStringExtra(Intent.ExtraPhoneNumber);
string stateStr = intent.Extras.GetString(TelephonyManager.ExtraState);
if (stateStr!=null)
{
if (stateStr.Equals(TelephonyManager.ExtraStateOffhook))
{ }
else if (stateStr.Equals(TelephonyManager.ExtraStateIdle))
{ }
}
}
}
and use with this code the following permissions:
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<uses-permission android:name="android.permission.READ_PRECISE_PHONE_STATE" />
And also with this receiver on AndroidManifest.xml
<receiver android:name="OutgoingBroadcastReceiver" android:enabled="true" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE_CHANGED" />
</intent-filter>
</receiver>
But it is fired only when the outgoing call is start or end. Please, Help me!!