我认为最简单的解决方案是实现一个扩展CountDownTimer的类。
首先,实现类:
class MyTimer extends CountDownTimer{
// first param is the total amount of time it will countdown
// second param is to fire onTick() method, in case you need to fire an alert or something
public CountDown(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
}
public void onTick(long millisUntilFinished) {
//You can fire a Toast from here indicating how much time is left
}
public void onFinish() {
//You can start the new activity from here
}
}
最后,你只需要创建和启动这个类的一个对象:
//3 minutes = 3 * 60 * 1000
new MyTimer(180000, 1000).start();
嗨,这是非常* *含糊。你可以添加更多关于你想要达到的细节 - 这是为所有用户吗?您的应用程序是否从中央服务器加载数据?会议何时开始并到期?另外,请添加正确的标签 - 'android'是最重要的 –
我正在创建一个测验应用程序。打开应用程序将打开主要活动,该活动将用户标识与数组中的数据进行比较。如果这是真的。它会继续下一个活动c1Activity,在该活动中将询问问题,并且用户需要输入等同于数组中存储值的答案。如果它是正确的,则用户进入下一个问题。同样的,直到最后一个问题。我的需求是用户应该在3分钟内回答所有问题,如果他迟滞应用程序应该打开显示时间的活动。 –
你可以编辑这个问题吗? –