Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
166 views
in Technique[技术] by (71.8m points)

java - How to end completely quit from activity with mp3 files

Hello I am making boxing countdown timer. And I am using ring tha inform me when round starts and end. And I would like to make "end" button with dialog "are you sure want to quit" and after click yes I would like to go to previously activity. And my problem is that I go after for example first round to previous activity but eariel I set for example 4 round I can hear in the background rings while I am on my previous activity. What should I do if I wanna end all task after click "yes"? Hope I add every important informations.

Code from my countdown

timerodprzerwy = new CountDownTimer(d?przerwy, 1000) {
    @Override
    public void onTick(long millisUntilFinished) {
        mTimeLeftInMillis = millisUntilFinished;
        updatetext2();
    }

    @Override
    public void onFinish() {
        MediaPlayer r2 = MediaPlayer.create(Main3Activity.this, R.raw.rinnkr);
        r2.start();
        tv6.setText("");
    }
}.start();

and code from my dialog:

btn1.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        AlertDialog.Builder dialog = new AlertDialog.Builder(Main3Activity.this);
        dialog.setMessage("Czy napewno chcesz wyj?? z trenignu?");
        dialog.setPositiveButton("Tak", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                Intent intent = new Intent(Main3Activity.this, Main5Activity.class);
                startActivity(intent);
            }
        });

        dialog.setNegativeButton("Nie", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

            }
        });
        AlertDialog dialogg = dialog.create();
        dialogg.show();
    }
});
question from:https://stackoverflow.com/questions/65933742/how-to-end-completely-quit-from-activity-with-mp3-files

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...