| Author |
How to identify when Accept Button is clicked.
|
Rakesh Jhamb
Ranch Hand
Joined: Jun 18, 2003
Posts: 154
|
|
Hi,
Is there a way to identify when Accept or Decline button are clicked when a phone call arrives. I am specifically looking for this event. The TelephonyManager.EXTRA_PHONE_STATE does not solve the purpose.
Thanks in advance.
|
SCJP2, SCWCD
|
 |
Hardik Trivedi
Ranch Hand
Joined: Jan 30, 2010
Posts: 252
|
|
|
I am not sure but there might be some broadcast receivers for that. Android has broadcast receivers like power button is pressed , ear-phones are p[lugged. Batter is removed etc etc. Same way there has to be something.
|
 |
Rakesh Jhamb
Ranch Hand
Joined: Jun 18, 2003
Posts: 154
|
|
There is a broadcast receiver for phone state, but I have not found one for accept or decline button. If someone, knows how to do this, please let me know.
Thanks.
|
 |
Hardik Trivedi
Ranch Hand
Joined: Jan 30, 2010
Posts: 252
|
|
TelephonyManager has something. Again I am not sure will this work or not.
TelephonyManager.CALL_STATE_IDLE
TelephonyManager.CALL_STATE_RINGING
TelephonyManager.CALL_STATE_OFFHOOK
|
 |
Rakesh Jhamb
Ranch Hand
Joined: Jun 18, 2003
Posts: 154
|
|
No, this doesn't work.
Using these options, you cannot differentatite which button was clicked.
Someone else, has an idea.
|
 |
Tibi Giurgiu
Greenhorn
Joined: Jul 01, 2011
Posts: 4
|
|
You can use onCallStateChanged (int state, String incomingNumber) method from android.telephony.PhoneStateListener.
This method gets called when the phone is ringing with state TelephonyManager.CALL_STATE_RINGING and after that it will be called again with TelephonyManager.CALL_STATE_OFFHOOK if the user accepts the call or TelephonyManager.CALL_STATE_IDLE if the call is rejected or not answered.
The same method will be invoked with TelephonyManager.CALL_STATE_OFFHOOK when you place a call but in this case the incomingNumber will be empty.
have a look here for an implementation
|
 |
Rakesh Jhamb
Ranch Hand
Joined: Jun 18, 2003
Posts: 154
|
|
|
It is the same thing. Even with onCallStateChanged(), you can't tell when accept or decline button is clicked. For example, you won't be able to distinguish between missed calls and rejected calls for example.
|
 |
 |
|
|
subject: How to identify when Accept Button is clicked.
|
|
|