I want to display one dialog box after incoming call, so that I can run my application in background while receiving call.
How to catch that incoming call in android application???
In AndroidManifest.xml you shoud make a receiver:
<receiver android:name="IncomingCallInterceptor">
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE"/>
</intent-filter>
</receiver>
and declare permission:
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
Then,
public class IncomingCallInterceptor extends BroadcastReceiver {
@Override
public void onReceive(final Context context, Intent intent) {
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
if (TelephonyManager.EXTRA_STATE_RINGING.equals(state)) {
// Phone is ringing
}
}
}
Maybe this broadcast intent is what you need ACTION_PHONE_STATE_CHANGED
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With