Code example for Timer

Methods: schedule

0
     * @see 
     * android.media.MediaPlayer.OnCompletionListener#onCompletion(android.media 
     * .MediaPlayer) 
     */ 
    public void onCompletion(MediaPlayer mediaplayer) {
        Timer endSound = new Timer();
        endSound.schedule(new TimerTask() {
            public void run() { 
                if (mp != null) {
                    mp.stop();
                    mp.release();
                    mp = null;
                } 
            } 
        }, 200); 
 
    } 
 
    /** 
     * Play sound, either locally (from assets) or remotely via URL.