Skip to content Skip to sidebar Skip to footer

How To Identify Incoming Call And Outgoing Call In Android

how to get the events of incoming call and outgoing call in android separately. Actually i was trying to develop an application that open on incoming call if number is exist in dat

Solution 1:

i want to restrict to open my application on outgoing call.

on case TelephonyManager.CALL_STATE_OFFHOOK: check if the previous state was CALL_STATE_RINGING or CALL_STATE_IDLE (for example by settings a different flag in both cases).
In the latter case proceed with opening your application, else do nothing


Solution 2:

add <action android:name="android.intent.action.NEW_OUTGOING_CALL" /> in your receiver and process it in your onReceive() method.

<receiver android:name=".IncomingCallReceiver" >
    <intent-filter >             
       <action android:name="android.intent.action.PHONE_STATE" />
       <action android:name="android.intent.action.NEW_OUTGOING_CALL" />             
    </intent-filter>
</receiver>

Solution 3:

The intent action android.intent.action.NEW_OUTGOING_CALL process the outgoing calls, but for the incoming call i suggest to check it this way:

if (intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)) {
        //outgoing call
} else if (intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER) != null) {
        //incoming call
}

Post a Comment for "How To Identify Incoming Call And Outgoing Call In Android"