title: Detect Whatsapp call and pause ExoPlayer
body: <p>I am developing an android Music Player application .I just want to pause when a call arrives , that has been acheived by the use of Telephony Manager , but i also wants to detect the Whatsapp calls and other internet calls .How to make that possible<br>
  This is my code what changes should be done to detect the internet calls also to pause the player on call and play on call ended</p>
  
  <pre><code>private void player_manager_on_call() {
      // TODO Auto-generated method stub
      // Manage player on Call
  
      phoneStateListener = new PhoneStateListener() {
  
          @Override
          public void onCallStateChanged(int state, String incomingNumber) {
              if (state == TelephonyManager.CALL_STATE_RINGING)
              // Incoming // call: // Pause // music
              {
  
                  try {
  
                      boolean is_playing = mediaController.Check_IsPlaying();
                      if (is_playing) {
                          Log.d("xiomi", "CALL_STATE_RINGING");
  
                          // Get details of song from sp
  
                          position = PlayerConstants.SONG_NUMBER;
  
                          data = PlayerConstants.SONGS_LIST.get(position);
  
                          Play_link = data.getPath();
                          Artist = data.getArtist() + "-" + data.getAlbum();
                          albumArt = UtilFunctions.getAlbumart(
                                  getApplicationContext(), data.getAlbumId());
                          Log.e("albumArt", "albumArt " + albumArt);
  
                          mediaController.doPauseResume();
                          showControls();
  
                          // start notification service again for play
  
                          startNotificationService(MainActivity.this,
                                  data.getTitle(), Artist, albumArt,
                                  is_playing, position);
  
                      }
                  } catch (Exception e) { // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
  
              } else if (state == TelephonyManager.CALL_STATE_IDLE) // Not in
                                                                      // //call:
                                                                      // //
                                                                      // Play
                                                                      // //
                                                                      // music
  
                  try {
  
                      if (player != null) {
                          Log.d("xiomi", "CALL_STATE_RINGING");
  
                          // Get details of song from sp
                          position = PlayerConstants.SONG_NUMBER;
  
                          data = PlayerConstants.SONGS_LIST.get(position);
  
                          Play_link = data.getPath();
                          Artist = data.getArtist() + "-" + data.getAlbum();
                          albumArt = UtilFunctions.getAlbumart(
                                  getApplicationContext(), data.getAlbumId());
                          Log.e("albumArt", "albumArt " + albumArt);
                          boolean is_playing = mediaController
                                  .Check_IsPlaying();
                          mediaController.doPauseResume();
                          showControls();
  
                          // start notification service again for play
  
                          startNotificationService(MainActivity.this,
                                  data.getTitle(), Artist, albumArt,
                                  is_playing, position);
  
                      }
                  } catch (Exception e) { // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
  
              else if (state == TelephonyManager.CALL_STATE_OFFHOOK) // A //
                                                                      // call
              // is // dialing, // active // or // on // hold
              {
  
                  try {
  
                      boolean is_playing = mediaController.Check_IsPlaying();
                      if (is_playing) {
                          Log.d("xiomi", "CALL_STATE_OFFHOOK");
  
                          // Get details of song from sp
  
                          position = PlayerConstants.SONG_NUMBER;
  
                          data = PlayerConstants.SONGS_LIST.get(position);
  
                          Play_link = data.getPath();
                          Artist = data.getArtist() + "-" + data.getAlbum();
                          albumArt = UtilFunctions.getAlbumart(
                                  getApplicationContext(), data.getAlbumId());
                          Log.e("albumArt", "albumArt " + albumArt);
  
                          mediaController.doPauseResume();
                          showControls();
  
                          // start notification service again for play
  
                          startNotificationService(MainActivity.this,
                                  data.getTitle(), Artist, albumArt,
                                  is_playing, position);
  
                      }
                  } catch (Exception e) { // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
  
              }
              super.onCallStateChanged(state, incomingNumber);
          }
      };
  
      TelephonyManager mgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
      if (mgr != null) {
          mgr.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
      }
  
  }
  </code></pre>