SharedPreferences sharedPreferences = getSharedPreferences("First",MODE_PRIVATE); final boolean isFirst = sharedPreferences.getBoolean("isFirst",true); Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { if(isFirst){ Intent intent = new Intent(TestForJump.this,SplashActivity.class); startActivity(intent); }else { Intent intent = new Intent(TestForJump.this,MainActivity.class); startActivity(intent); } }},300);
在程序入口插入SharedPreferences 首次获取"isFirst" 值,因为没有,所以赋值 true
那么就进入到向导界面SplashActivity中 然后在SplashActivity中改变"isFirst"
即可实现第二次进入程序不再出现向导界面了,如下所示(在SplashActivity中添加代码):
SharedPreferences sharedPreferences = getSharedPreferences("First",MODE_PRIVATE); SharedPreferences.Editor edit = sharedPreferences.edit(); edit.putBoolean("isFirst",false); edit.commit();
如果觉得可以 请打赏小小意思
android首次安装app时欢迎界面进入向导界面再进入到主界面
最新推荐文章于 2019-06-10 09:47:22 发布