点点英语,魔易乾坤,萧如瑟五十弦
本文实例为大家分享了android判断程序是否第一次启动的具体代码,供大家参考,具体内容如下
public class welcome extends activity { private final long splash_length = 2000; handler handler = new handler(); public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.farst_img); //定义一个setting记录app是几次启动!!! sharedpreferences setting = getsharedpreferences("com.example.hr_jie", 0); boolean user_first = setting.getboolean("first", true); if (user_first) {// 第一次则跳转到欢迎页面 setting.edit().putboolean("first", false).commit(); tiaozhuanzhu(); } else {//如果是第二次启动则直接跳转到主页面 tiaozhuanfu(); } } public void tiaozhuanzhu(){ handler.postdelayed(new runnable() { //使用handler的postdelayed实现延时跳转 public void run() { intent intent = new intent(welcome.this, welcome_four.class); startactivity(intent); finish(); } }, splash_length);//2秒后跳转至应用主界面mainactivity } public void tiaozhuanfu(){ handler.postdelayed(new runnable() {//使用handler的postdelayed实现延时跳转 public void run() { intent intent = new intent(welcome.this, mainactivity.class); startactivity(intent); finish(); } }, splash_length);//2秒后跳转至应用欢迎界面 } }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Android studio 解决logcat无过滤工具栏的操作
Android Studio 恢复小窗口停靠模式(Docked Mode)
Android studio保存logcat日志到本地的操作
Android Studio快捷键生成TAG、Log.x日志输出介绍
网友评论