title: Interrupt a postdelayed from a handler inside a OnCompletionListener
body: <p>I have several different Activitys each with a MediaPlayer and a OnCompletionListener to start other activities after the current file has stopped playing. There also is a delay built in the OnCompletion Listener which i achieve through a Handler with postDelayed and it looks like this:</p>
  
  <pre><code>public void onCompletion(MediaPlayer mp) {
  
          Handler handler = new Handler();
          handler.postDelayed(new Runnable() {
              @Override
              public void run() {
                  try {
                      Intent stopplay;
                      stopplay = new Intent(actualActivity, Class
                              .forName(nextView));
                      actualActivity.startActivity(stopplay);
                  } catch (ClassNotFoundException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
              }
          }, stopTime);
  
  
  }
  </code></pre>
  
  <p>The problem with this is, when i call my SettingsActivity, sometimes it just switches to the Activity that would have come next. So i assume it's hanging in the postDelayd's wait...</p>
  
  <p>How could i get around this?</p>
  
  <p>I also do this in the onStop, onPause and onDestroy of these Activities: </p>
  
  <pre><code>if (mPlayer != null) {
          mPlayer.stop();
          mPlayer.release();
          mPlayer = null;
      }
  </code></pre>