嗨,我正在做倒计时,当我的计时器运行我的应用程序读我拳击组合,我做了一个对话框,点击按钮后,我看到“你确定要退出”和点击是后,我的应用程序去以前的活动,但仍然阅读组合。这里是我的问题,我想取消我的运行倒计时或使函数,如果(我的计时器运行){阅读组合}。有可能吗?我的代码看起来
timerodkombosa = new CountDownTimer(dłrundy, 5000) {
@Override
public void onTick(long millisUntilFinished) {
final Random rand = ThreadLocalRandom.current();
tv3.setText(kombosy[new Random().nextInt(kombosy.length)]);
switch (tv3.getText().toString()) {
case "1-2":
MediaPlayer ring = MediaPlayer.create(Main3Activity.this, R.raw.rin1);
ring.start();
break;
case "1-1-2":
MediaPlayer ring2 = MediaPlayer.create(Main3Activity.this, R.raw.rin2);
ring2.start();
break;
case "1-2-3-2":
MediaPlayer ring3 = MediaPlayer.create(Main3Activity.this, R.raw.rin3);
ring3.start();
break;
case "1-2-5-2":
MediaPlayer ring4 = MediaPlayer.create(Main3Activity.this, R.raw.rin4);
ring4.start();
break;
case "1-6-3-2":
MediaPlayer ring5 = MediaPlayer.create(Main3Activity.this, R.raw.rin5);
ring5.start();
break;
case "2-3-2":
MediaPlayer ring6 = MediaPlayer.create(Main3Activity.this, R.raw.rin6);
ring6.start();
break;
}
}
@Override
public void onFinish() {
tv3.setText("");
if (licz > 1) {
round_count1[0]++;
if (round_count1[0] < finalNum_rounds) {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
start();
}
}, dłprzerwy);
timerodprzerwy = new CountDownTimer(dłprzerwy, 1000) {
@Override
public void onTick(long millisUntilFinished) {
mTimeLeftInMillis = millisUntilFinished;
updatetext();
}
@Override
public void onFinish() {
}
}.start();
}
}
}
}.start();
}
}.start();
暂无答案!
目前还没有任何答案,快来回答吧!