title: MediaPlayer.setOnCompletionListener not executing
body: <pre><code>public class MainActivity extends AppCompatActivity
              implements View.OnClickListener {
  
          private MediaPlayer mediaPlayer;
          private ImageButton playBtn,previousBtn,forwardBtn,rewindBtn,nextBtn;
          private SeekBar seekBar;
          private int[] songsName = {R.raw.song1,R.raw.song2,R.raw.song3,R.raw.song4};
          private int songPosition=0;
  
  
              @Override
                  protected void onCreate(Bundle savedInstanceState) {
                      super.onCreate(savedInstanceState);
                      setContentView(R.layout.activity_main);
  
                      seekBar = (SeekBar) findViewById(R.id.songProgressBar);
                      seekBar.setClickable(false);
                      seekBar.setEnabled(false);
                      playBtn = (ImageButton) findViewById(R.id.play);
                      playBtn.setOnClickListener((View.OnClickListener)this);
                      seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                      @Override
                      public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
  
                          if(mediaPlayer != null &amp;&amp; b){
                              mediaPlayer.seekTo(i);
                          }
  
                      }
                      @Override
                      public void onStartTrackingTouch(SeekBar seekBar) {
                      }
  
                      @Override
                      public void onStopTrackingTouch(SeekBar seekBar) {
                      }
                  });
  
                  forwardBtn = (ImageButton) findViewById(R.id.forward);
                  forwardBtn.setOnClickListener((View.OnClickListener)this);
  
                  rewindBtn = (ImageButton) findViewById(R.id.rewind);
                  rewindBtn.setOnClickListener((View.OnClickListener)this);
  
                  nextBtn = (ImageButton) findViewById(R.id.next);
                  nextBtn.setOnClickListener((View.OnClickListener)this);
  
                  previousBtn = (ImageButton) findViewById(R.id.previous);
                  previousBtn.setOnClickListener((View.OnClickListener)this);
  
                  subView = (SubtitleView) findViewById(R.id.subs_box);
  
                      mediaPlayer = new MediaPlayer();
                      mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
  
                          @Override
                          public void onCompletion(MediaPlayer mediaplayer) {
  
                              Toast.makeText(getApplicationContext(),"Media Player End",Toast.LENGTH_LONG).show();
             nextSong();
  
                          }
                      });
              }
  
  @Override
      public void onClick(View view) {
          switch (view.getId()){
              case R.id.play:
                   playSong();
                   break;
              case R.id.forward:
                  forwardSong(5000);
                   break;
              case R.id.rewind:
                   rewindSong(5000);
                   break;
              case R.id.next:
                   if(mediaPlayer !=null)
                       nextSong();
                   break;
              case R.id.previous:
                   previousSong();
                   break;
          }
      }
  
      public void playSong(){
          imageName = (String) playBtn.getTag();
          if(imageName.equals("play")) {
              playBtn.setTag("stop");
              //mediaPlayer = MediaPlayer.create(this, R.raw.chalisa);
              Log.d(TAG,""+songPosition);
              prepareMediaPlayer(songPosition);
              seekBar.setMax(mediaPlayer.getDuration());
              seekUpdation();
              seekBar.setEnabled(true);
              playBtn.setImageResource(R.drawable.stop);
          }else{
              playBtn.setImageResource(R.drawable.play);
              playBtn.setTag("play");
              mediaPlayer.pause();
              mediaPlayer = null;
              seekBar.setProgress(0);
              seekBar.setEnabled(false);
              subView.setText("");
          }
      }
  
      public void forwardSong(int time){
          if(mediaPlayer != null){
              mediaPlayer.seekTo(mediaPlayer.getCurrentPosition() + time);
          }
  
      }
  
      public void rewindSong(int time){
          if(mediaPlayer != null){
              mediaPlayer.seekTo(mediaPlayer.getCurrentPosition() - time);
          }
      }
  
      public void nextSong(){
          songPosition++;
          if(songPosition &lt; songsName.length){
              mediaPlayer.pause();
              seekBar.setProgress(0);
              mediaPlayer.seekTo(0);
              mediaPlayer = null;
              prepareMediaPlayer(songPosition);
          }else{
              mediaPlayer.pause();
              seekBar.setProgress(0);
              mediaPlayer.seekTo(0);
              songPosition = 0;
              mediaPlayer = null;
              prepareMediaPlayer(songPosition);
          }
      }
  
      public void previousSong(){
          songPosition--;
          if (songPosition != -1){
              mediaPlayer.pause();
              seekBar.setProgress(0);
              mediaPlayer.seekTo(0);
              mediaPlayer = null;
              prepareMediaPlayer(songPosition);
          }else{
              mediaPlayer.pause();
              seekBar.setProgress(0);
              mediaPlayer.seekTo(0);
              songPosition = 0;
              mediaPlayer = null;
              prepareMediaPlayer(songPosition);
          }
  
  
  
      }
  
  
      public void prepareMediaPlayer(int songPosition){
          mediaPlayer = MediaPlayer.create(this, songsName[songPosition]);
          mediaPlayer.start();
          subView.setPlayer(mediaPlayer);
          subView.setSubSource(subTitleName[songPosition], MediaPlayer.MEDIA_MIMETYPE_TEXT_SUBRIP);
  
      }
  
      public void seekUpdation() {
          if(mediaPlayer != null) {
              seekBar.setProgress(mediaPlayer.getCurrentPosition());
              myHandler.postDelayed(run, 1000);
          }
      }
  
      Runnable run = new Runnable() {
          @Override public void run()
          {
              seekUpdation();
          }
      };
  </code></pre>
  
  <p>media player on completion not working, not able to print the log also.</p>
  
  <p>My intention is to play the next song once the current song is completed, but i am not able to check the song is completed or not.</p>
  
  <p>In the logcat, it is showing the below warning</p>
  
  <p>W/MediaPlayer-JNI(16888): MediaPlayer finalized without being released.</p>
  
  <p>not showing any error in the logcat......</p>
  
  <p>What may be the issue?</p>
  
  <p>Anything wrong with the MediaPlayer.onCreate?</p>