1、利用Handler的postDelayed
new Handler().postDelayed(new Runnable() { @Override public void run() { Intent intent = new Intent(MainActivity.this, ExampleActivity.class); startActivity(intent); } }, 3000); // 3秒后执行
2、利用timer的schedule
final Intent localIntent = new Intent(this, ExampleActivity.class); Timer timer = new Timer(); TimerTask tast = new TimerTask() { @Override public void run() { startActivity(localIntent); } }; timer.schedule(tast, 5000); // 5秒后执行task的run
评论