I’m trying to make a splash screen for my Android app, where the login page just starts the Splash activity, and then all the login processing stuff is done there. It then returns a boolean whether login succeeded or not. But the login processing completes before the XML layout content loads. How can this be fixed?
This is my splash screen activity:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle extras = getIntent().getExtras();
if(extras !=null)
{
url = extras.getString("url");
}
setContentView(R.layout.splashscreen);
url += "login/?userName=" + Login.loginName + "&password=" + Login.password;
DomLoginParser parser = new DomLoginParser(url);
if(parser.parse())
{
Login.loginSuccessful = true;
}
else
{
Login.loginSuccessful = false;
}
finish();
}
Move the login out of the onCreate call by using AsyncTask to perform the login.
What you are doing is finishing the activity before giving it a chance to show the contents.
The activity is showing the contentView only after the onCreate call is finished…