문제

Hi In My Application I am playing one audio if i click back or home button that window should stop i am new to android please help me

final MediaPlayer mp = new MediaPlayer();
button1.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View arg0) {
                    // TODO Auto-generated method stub
                    Intent nextScreen = new Intent(getApplicationContext(), Demovote2.class);
                    startActivity(nextScreen);
                    mp.start();
                    finish();

                }
            });



    }
도움이 되었습니까?

해결책

you should stop it on onpause method and replay it on onresume,

 @Override
    protected void onPause() {
        mp.stop();
        super.onPause();
    }

@Override
public void onResume(){

    // put your code here...
    mp.start();
     super.onPause();
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top