This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to identify when Accept Button is clicked.

 
Rakesh Jhamb
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Hardik Trivedi
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, this doesn't work.

Using these options, you cannot differentatite which button was clicked.

Someone else, has an idea.
 
Tibi Giurgiu
Greenhorn
Posts: 4
Android Linux Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic