レイアウトにタイマーを表示する必要があるアプリケーションを実装しています。タイマーのカウントダウンが 0 秒になるとアプリは続行し、パスが定義されている別のアプリに自動的に進む必要があります。
2 に答える
2
あなたはこのようにすることができ、onFinishで他のアプリをロードします
private class MyCount extends CountDownTimer{
public MyCount(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
}
@Override
public void onTick(final long millisUntilFinished) {
long min = 0, sec = 0, totalSec = 0;
totalSec = (millisUntilFinished/1000);
min = totalSec/60;
sec = totalSec%60;
final long m = min;
final long s = sec;
runOnUiThread(new Runnable() {
public void run() {
System.out(" "+ m +"m and "+s+"s remaining.");
// or Display the way you want
}
});
}
@Override
public void onFinish() {
//load the task you want to do
}
}
このように呼ぶことができます
MyCount counterr = new MyCount(sec *1000 , 1000);// sec = number of seconds
counterr.start();
于 2012-11-07T09:44:57.950 に答える
1
CountDownTimer
私はこのタスクに使用したでしょう。onFinish メソッドを使用して、他のアクティビティを呼び出します。
new CountDownTimer(timetocomplete, ticks) {
@Override
public void onTick(long millisUntilFinished) {
}
@Override
public void onFinish() {
// Intent to start a new activity
}
}.start();
于 2012-11-07T09:45:45.583 に答える