• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps How to detect incoming call

uaeHamed

Newbie
Hi. Im working on an application that does something during a call. So I understand I need to use a service. But how does my application detect that a call is incoming or the call is answered or whatever before I launch the service?
 
To listen for change in calls you can use a broadcast with action: android.intent.action.PHONE_STATE:
Code:
<receiver android:name=".CallReceiver">
        	<intent-filter>
        		<action android:name="android.intent.action.PHONE_STATE" />
        	</intent-filter>
        </receiver>
And you can check the EXTRA_STATE in the intent given with the broadcast:
Code:
String callState = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
 
Back
Top Bottom