When the application starts or resumes, I would like to redirect the user to a specific “Activity” based on the variable set in “SharedPrefences”.
To do this, I considered using a method that checks the SharedPreferences state variable and redirects to the correct activity:
private void launchRedirect(Context ctxt) {
Integer status = AppPreferences.getStatus(this);
Intent i = new Intent(MainActivity.this, Activity1.class);
switch (status) {
case 0:
i = new Intent(MainActivity.this, Activity2.class);
case 1:
i = new Intent(MainActivity.this, Activity3.class);
case 2:
i = new Intent(MainActivity.this, Activity4.class);
case 3:
i = new Intent(MainActivity.this, Activity5.class);
}
startActivity(i);
}
And then I could call this method in every onResume method for every action in my application:
public void onResume(Bundle savedInstanceState) {
launchRedirect(this);
}
This means that the user cannot technically return to the last Activity, because when he calls it, he calls onResume, and he will be redirected to the state corresponding to the current user.
, , - ?