使用Timer实现延迟welcome界面2秒后启动主activity

来源:互联网 发布:python中文手册下载 编辑:程序博客网 时间:2024/06/04 00:43
01 public class welcome extends Activity {02     public void onCreate(Bundle savedInstanceState) {03         super.onCreate(savedInstanceState);04         this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏 05         this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
WindowManager.LayoutParams.FLAG_FULLSCREEN);//去掉信息栏06         setContentView(R.layout.welcome);07         final Intent intent2 = new Intent(welcome.this,08                 MainActivity.class);09         Timer timer = new Timer();10         TimerTask task = new TimerTask() {11             @Override12             public void run() {13                 startActivity(intent2);14                 finish(); // 执行15             }16         };17         timer.schedule(task, 1000 * 2); // 2秒后18 19     }20 }

0 0
原创粉丝点击