2
I have the following problem: I have a splash screen which will be called only if it is the first execution of the application. If it’s not the first execution I’d like to call another Activity.
I tried the following... to make a InitialActivity
just like below:
public class InitialActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_initial);
final SharedPreferences sharedPref = getPreferences(MODE_PRIVATE);
boolean isFirstUse = sharedPref.getBoolean("is_first_use", true);
if (isFirstUse)
{
SharedPreferences.Editor editor = sharedPref.edit();
editor.putBoolean("is_first_use", false);
editor.commit();
startActivity(new Intent(this, SplashScreen.class));
} else {
//verify mode and call correct activity
startActivity(new Intent(this, MainActivity.class));
}
}
}
The problem is this guy calls the super.onCreate
and ends up creating this Activity. Turns out it shows a white screen before deciding which Activity initial i want to go.
How can I solve this problem?
This will not disrupt code execution after onCreate?
– Valter Junior
It won’t. The code will be executed normally and after the
onCreate()
theonDestroy()
will be executed.– Luídne