Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I completely agree with Michael there is no robust way of finding out when the call has been answered by the calle in android. i.e TelephonyManager. <strong>CALL_STATE_OFFHOOK</strong> will set as soon as you make a call.</p> <p>try this example you will understand </p> <pre><code>public class BroadcastReceiverImpl extends BroadcastReceiver{ @Override public void onReceive(Context context, Intent intent) { Toast.makeText(context, "Monitoring The Network !! ", Toast.LENGTH_LONG).show(); PhoneStateListnerImpl phoneStateListnerImpl = new PhoneStateListnerImpl(context); TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(context.TELEPHONY_SERVICE); telephonyManager.listen(phoneStateListnerImpl, PhoneStateListener.LISTEN_CALL_STATE); } private class PhoneStateListnerImpl extends PhoneStateListener{ private Context mContext; public PhoneStateListnerImpl(Context mContext) { this.mContext = mContext; } @Override public void onCallStateChanged(int state, String incomingNumber) { switch (state) { case TelephonyManager.CALL_STATE_RINGING: Toast.makeText(mContext, "Phone is Ringng ", Toast.LENGTH_LONG).show(); break; case TelephonyManager.CALL_STATE_OFFHOOK: Toast.makeText(mContext, "Phone is Answered ", Toast.LENGTH_LONG).show(); break; case TelephonyManager.CALL_STATE_IDLE: Toast.makeText(mContext, "Call Is Over ", Toast.LENGTH_LONG).show(); abortBroadcast(); break; default: break; } } } } manifest : &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.pervazive.monitor_network_v08" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16" /&gt; &lt;uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" /&gt; &lt;uses-permission android:name="android.permission.READ_PHONE_STATE" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt; &lt;uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /&gt; &lt;application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;receiver android:name="com.example.broadcastreceiver.BroadcastReceiverImpl" android:enabled="true" android:exported="true" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.ACTION_PHONE_STATE_CHANGED" /&gt; &lt;action android:name="android.intent.action.ACTION_NEW_OUTGOING_CALL" /&gt; &lt;action android:name="android.intent.action.PHONE_STATE" /&gt; &lt;action android:name="android.intent.action.NEW_OUTGOING_CALL" /&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload