Code example for SoundPool

Methods: release

0
    // onDestroyではなくonPauseでrelease()する 
    @Override 
    public void onPause() { 
        super.onPause(); 
        mMediaPlayer.release();
        mSoundPool.release();
    } 
 
    public void onStartButton(View view) {
        if (isPrepared) {
            mMediaPlayer.start();
        } else { 
            Toast.makeText(this, "音声ファイルをロード中でやんす",
                           Toast.LENGTH_LONG).show();
        } 
    } 
 
    public void onPauseButton(View view) {
        if (mMediaPlayer.isPlaying()) {
            mMediaPlayer.pause();
        }