Making an activity appear only once, when the app is started

后端 未结 2 2045
暗喜
暗喜 2020-12-10 17:48

I have the following class, SplashActivity.java:

public class SplashScreen extends Activity{

    @Override
    protected void onCreate(Bund         


        
2条回答
  •  被撕碎了的回忆
    2020-12-10 17:51

     SharedPreferences pref = getSharedPreferences("ActivityPREF",    Context.MODE_PRIVATE);
         if(pref.getBoolean("activity_executed", false)){
    
    } else { 
       Intent intent = new Intent(this, TutorialOne.class);
        startActivity(intent);
        finish();
        Editor ed = pref.edit();
        ed.putBoolean("activity_executed", true);
        ed.commit();
    } 
    

    I think it should be like this.

提交回复
热议问题