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();
}
});