uaeHamed

Newbie
May 22, 2011
20
1
16
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);
 
  • Like
Reactions: uaeHamed