Android display a screen only the first time you open the application

3

Is there a way to run a specific screen (such as ID) the first time the application is opened? And every time I launch an update in google play, people who already have the app installed and reopen after the update, will the idle screen be displayed again? is there a way to differentiate those who download to those who receive an update?

    
asked by anonymous 12.05.2015 / 14:23

1 answer

3

Use SharedPreferences to save the app version.

In the main activity, in the oncreate() method, obtain this information and act accordingly.

String appVer = "versão actual da sua app";
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
String appVer = preferences.getString("lastAppVer","");

if(lastAppVer == ""){
    // A aplicação foi instalada pela primeira vez
    // Exibir tela
}
else if(lastAppVer != appVer){
    // A aplicação foi actualizada
    // Exibir tela
}

In the screen activity to be displayed only once save the version of your app in SharedPreferences

String appVer = "versão actual da sua app";
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
preferences.edit.putString("lastAppVer",appVer).apply();  
    
12.05.2015 / 14:59