Android: First run popup dialog

前端 未结 6 2185
感情败类
感情败类 2020-12-04 11:50

I am trying to make a popup dialog that only shows after the app\'s first run that will alert users of the new changes in the app. So I have a dialog popup like this:

<
6条回答
  •  甜味超标
    2020-12-04 12:10

     loginPreferences = getSharedPreferences("loginPrefs", MODE_PRIVATE);
     loginPrefsEditor = loginPreferences.edit();
     doFirstRun();
    
     private void doFirstRun() {
            SharedPreferences settings = getSharedPreferences("PREFERENCE", MODE_PRIVATE);
            if (settings.getBoolean("isFirstRun", true)) {
                loginPrefsEditor.clear();
                loginPrefsEditor.commit();
                SharedPreferences.Editor editor = settings.edit();
                editor.putBoolean("isFirstRun", false);
                editor.commit();
            }
        }
    

    I used this code to ensure that its the first time someone runs the application. The loginPrefsEditor is cleared from data because i have a "Remember Me" Button which stores the data to the sd card. Hope it helps !

提交回复
热议问题