This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Android and the fly likes How to identify when Accept Button is clicked. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "How to identify when Accept Button is clicked." Watch "How to identify when Accept Button is clicked." New topic
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.
 
wood burning stoves
 
subject: How to identify when Accept Button is clicked.
 
Similar Threads
Actionevent
more than one click on a button
creating button with dual purpose
how to identify rich datascroller paination button click event
Find source of button click