Tuesday, 15 July 2014

android - How to detect when phone is answered or rejected -


I ring the phone when an activity has been successful Now I have to know that when I call the caller I do or reject the call, then how to cancel this activity. Do I call EXTRA_STATE_IDLE? EXTRA_STATE_OFFHOOK?

Any thoughts?

  & lt; Receiver Android: name = "IncomingBroadcastReceiver" & gt; & Lt; Intent-Filter & gt; & Lt; Action Android: name = "android.intent.action.PHONE_STATE" /> & Lt; / Intent-Filter & gt; & Lt; / Receiver & gt; Public Class Incoming Broadcast Receiver Expands Broadcast Receiver {@ Override Available on Public Empty (Reference Reference, Intent of Intent) {String State = Intent.getStringExtra (TelephonyManager.EXTRA_STATE); // If an incoming call arrives (state .flens (telephony manager. EXTRA_STATE_RINGING)) {// My work}  

In your on receiver:

  PhoneStateChangeListener pscl = New PhoneStateChangeListener; Telephony Manager TM = (Telephony Manager) This. Gate System System (Reference. TELEPHONY_SERVICE); Tm.listen (pscl, PhoneStateListener.LISTEN_CALL_STATE);  

Different classes:

  Private class PhonSTat Change Expands Extensile Phonestate Listener {Was a Public Stabilization Boolean; {@} (Local) {call telephony manager at @ColStateChanged (int state, string incoming number). CALL_STATE_RINGING: Override public null at Log.i (LOG_TAG, "Ringing"); Thering = true; break; Case Telephony Manager. CALL_STATE_OFFHOOK: Logs. I (LOG_TAG, "OFFHOOK"); If (had to have done!) {// Start your new activity} Other {// Cancel your old activity} // It should have been the last part of the code before the break; Ringing = true; break; Case Telephony Manager. CALL_STATE_IDLE: Logs. I (LOG_TAG, "IDLE"); // It should have been the last piece of code before the break; rolling = falls; break; }}}  

You just have to type some code, to check if the previous state was 'ringing' if the current status is inactive and the previous condition is ringing, they cancels the call done. If the current situation has been violated and the previous state is ringing, they answer the call.


No comments:

Post a Comment