本篇内容主要讲解“短视频平台开发实现页面自动跳转的方法是什么”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“短视频平台开发实现页面自动跳转的方法是什么”吧!
1.通过Timer计时器
public class WelcomeActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Intent it = new Intent(this, MainActivity.class);
Timer timer = new Timer();
TimerTask task = new TimerTask() {
@Override
public void run() {
startActivity(it);
}
};
timer.schedule(task, 1000 * 3);
}
}
2.通过Handler延时发送消息
public class SplashActivity extends AppCompatActivity {
private static final int START_ACITIVIY = 0X1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
handler.sendEmptyMessageDelayed(START_ACITIVIY,3000);
}
private Handler handler=new Handler() {
@Override
public void handleMessage(@NonNull Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case START_ACITIVIY:
startActivity(new Intent(SplashActivity.this, MainActivity.class));
finish();
break;
}
}
};
}
到此,相信大家对“短视频平台开发实现页面自动跳转的方法是什么”有了更深的了解,不妨来实际操作一番吧!这里是天达云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!