android 延时跳转页面的两种方法
一、利用handler延时跳转
new Handler(new Handler.Callback() {
@Override
public boolean handleMessage(Message msg) {
Intent intent=new Intent(MainActivity.this,Main2Activity.class);
startActivity(intent);
return false;
}
}).sendEmptyMessageDelayed(0x123,3000);//延时3秒跳转
二、使用Timetask
final Timer timer=new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
Intent intent=new Intent(MainActivity.this,Main2Activity.class);
startActivity(intent);
timer.cancel();
}
},2000);