Media Player


Android Multithreading Public

Hard  

3min


Consider the following code:

@Override
protected void onResume() {
    super.onResume();
    mp = MediaPlayer.create(getBaseContext(), R.raw.sound);
    Thread timer = new Thread() {
        @Override
        public void run() {
            try {
                Thread.sleep(1000);
                Intent main = new Intent(Splash.this, MainActivity.class);
                startActivity(main);
                finish();
            } catch (InterruptedException e) {}
        }
    };
    timer.start();
    mp.start();
}

@Override
protected void onPause() {
    super.onPause();
    if (mp != null) {
        if (mp.isPlaying()) {
            mp.stop();
        }
        mp.release();
        mp = null;
    }
}

Select all of the statements that are correct if the wave file sound is 3 seconds long.

(multiple correct answers possible)