Android 整个活动的倒计时
我有多个活动,比如说N个活动Android 整个活动的倒计时,android,android-activity,countdowntimer,Android,Android Activity,Countdowntimer,我有多个活动,比如说N个活动 当活动开始时,倒计时开始 这是我的问题吗? 倒计时开始后,我想切换到另一个活动。这样,当活动更改为另一个活动时,倒计时应该恢复。… 有人能给我一个合适的例子来回答吗 提前感谢通过意向将计时器的开始时间发送给其他活动。因此: long timerStarted = System.currentTimeMillis(); Intent intent = new Intent(this, AnotherActivity.class); intent.putExtra("
当活动开始时,倒计时开始
这是我的问题吗?
倒计时开始后,我想切换到另一个活动。这样,当活动更改为另一个活动时,倒计时应该恢复。…
有人能给我一个合适的例子来回答吗
提前感谢通过意向将计时器的开始时间发送给其他活动。因此:
long timerStarted = System.currentTimeMillis();
Intent intent = new Intent(this, AnotherActivity.class);
intent.putExtra("timerStarted", timerStarted);
然后在下一个活动中使用
getIntent().getLongExtra("timerStarted", System.currentTimeMillis());
您将使计时器与上一活动中的开始时间保持一致。您可以使用与splashScreen中相同的代码
new Handler().postDelayed(new Runnable() {
/*
* Showing splash screen with a timer.
*/
@Override
public void run() {
// This method will be executed once the timer is over
Intent i = new Intent(Act1.this, Act2.class);
startActivity(i);
// close this activity
finish();
}
}, SPLASH_TIME_OUT);
当一个活动开始倒计时时,开始这一步,直到目前为止我才尝试过