Search code examples
androidtelephonymanager

Ringing State Out Going Calls


I have the following code and I have read that for outgoing calls ringing state is active when phone call between two parties is connected and other party can actually see that you are calling and answer your call. Idle State is when call is disconnected and OFF_HOOK state is the moment when you press the button to dial.I am getting in OFF_HOOK and IDLE state but can't get in ringing state .What might be the problem? .Any help will be appreciated.

public void onReceive(final Context context, Intent intent) {
            TelephonyManager Tm=(TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
            Tm.listen(new PhoneStateListener(){
                public void  onCallStateChanged(int state,String number) {
                    super.onCallStateChanged(state, number);
                    switch (state) {
                      case TelephonyManager.CALL_STATE_IDLE:
                          //when Idle i.e no call
                          Toast.makeText(context, "Phone state Idle", 1).show();

                          break;
                      case TelephonyManager.CALL_STATE_OFFHOOK:

                          //when Off hook i.e in call
                          //Make intent and start your service here
                          Toast.makeText(context, "Phone state Off hook", 1).show();

                          break;
                      case TelephonyManager.CALL_STATE_RINGING:
                          Toast.makeText(context, "Phone state Ringing", 1).show();
                        break;


                      default:
                          break;
                      }
                  }    

            },PhoneStateListener.LISTEN_CALL_STATE);

Solution

  • TelephonyManager.CALL_STATE_RINGING is meant for the incoming call. Its not for the ringing of other side for an outgoing call.

    TelephonyManager.CALL_STATE_RINGING will be triggered when you have an incoming call and your phone is ringing.

    and also for your information. There is no public api to detect the ringing state of other side for outgoing call.