title: Incoming and outgoing calls in the BroadcastReceiver
body: <p>There is a service in which the processed media player would want to do that for an incoming and outgoing call service stopped media player, and at the end of the call flow resumes playback. 
  Now only managed to stop playback on incoming and outgoing calls, should add code to play TelephonyManager.CALL_STATE_IDLE: then the talking after a while the music starts, how to fix it? </p>
  
  <pre><code>public class CallReceiver extends BroadcastReceiver{
  TelephonyManager telManager;
  Context context;
  boolean startedCall = false;
  
  @Override
  public void onReceive(Context context, Intent intent) {
  
  
  this.context=context;
  
  
  telManager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
  telManager.listen(phoneListener, PhoneStateListener.LISTEN_CALL_STATE);
  
  }
  
  private final PhoneStateListener phoneListener = new PhoneStateListener() {
  @Override
  public void onCallStateChanged(int state, String incomingNumber) {
      super.onCallStateChanged(state, incomingNumber);
      try {
          switch (state) {
          case TelephonyManager.CALL_STATE_RINGING: {
              if(incomingNumber!=null)
              {
                  //incoming call
                  MediaService.stopMP();
                  startedCall  = true;
              }
  
          break;
          }
          case TelephonyManager.CALL_STATE_OFFHOOK: {
              if(incomingNumber!=null)
              {
                  //outgoing call
                  MediaService.stopMP();
                  startedCall  = true;
              }
  
          break;
          }
          case TelephonyManager.CALL_STATE_IDLE: {
              if(startedCall)
              {
                  MainActivity.titleMusic.setVisibility(View.VISIBLE);
                  MainActivity.Play();
                  MediaService.startMP();
                  startedCall = false;
              }                   
  
          break;
          }
          default: { }
          }
          } catch (Exception ex) {
  
          }
      }
  };
  }
  </code></pre>