Reputation:
I'm developing an application which should:
More specifically, I don't want the application to begin while the phone is ringing, but when the actual conversation is begins (aka, the user has accepted the incoming call).
Does anyone know how to do this? And how to catch these events?
Upvotes: 0
Views: 474
Reputation: 2194
What you want is provided by the TelephonyManager.
You should create a BroadcastReceiver which listens for ACTION_PHONE_STATE_CHANGED. When you declare it in your AndroidManifest.xml it will spawn your service/activity. When you are spawned it's very likely that the phone is currently just in the ringing state. So you have to register for further changes of the PhoneState via TelephonyManager.listen(). This way you will notice when the phone got hooked off and also when it goes back to idle.
Don't forget to request the READ_PHONE_STATE permission.
Upvotes: 1
Reputation: 1807
Broadcast Receiver will help you. Here's the official google developer page on it.
Here is a small tutorial on the same.
Upvotes: 1