title: Android: How to display message when call is received and ended?
body: <p>i am applying the following code to display message for three state,</p>
  
  <p>1) call rejected
  2) call received
  3) call ended</p>
  
  <pre><code>     TelephonyManager telephonyManager;
  
       PhoneStateListener listener = new PhoneStateListener() {
  
  public void onCallStateChanged(int state,String incomingNumber) {
  
  switch (state) {
  
  case TelephonyManager.CALL_STATE_IDLE:
  
  
  Toast.makeText(c, "Call Ended..",Toast.LENGTH_LONG).show();
  
      Log.i("stop", "Call Ended....");
  
          break;
  
  case TelephonyManager.CALL_STATE_OFFHOOK:
  
       Toast.makeText(c, "Call Picked..",Toast.LENGTH_LONG).show();
      Log.i("received", "Call Picked....");
  
  
          break;
  
  case TelephonyManager.CALL_STATE_RINGING:
  
       Toast.makeText(c, "Call Ringing.." + phonenumber,
      Toast.LENGTH_LONG).show();
                  break;
      }
  
      }
  
      };
  // Register the listener with the telephony manager
  telephonyManager.listen(listener,PhoneStateListener.LISTEN_CALL_STATE);
  
          }
  </code></pre>
  
  <p>when i am rejecting call , then also it goes in hook_state, how to display message for two separate received and call declined/rejected</p>
  
  <p>Thanks in advance..</p>
  
  <p>Please help</p>