Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show incoming call notification in android application

Tags:

android

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???

like image 289
Akshata Avatar asked May 05 '10 08:05

Akshata


2 Answers

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

    }


}

}
like image 67
defhlt Avatar answered Oct 02 '22 21:10

defhlt


Maybe this broadcast intent is what you need ACTION_PHONE_STATE_CHANGED

like image 38
hara Avatar answered Oct 02 '22 23:10

hara