I have an activity for a splash screen which has only an image in the layout. I want to make some Http calls in the background while the splash screen is displayed in the UI thread. But when I execute the AsyncTask the image in the layout is not displayed. I get only a blank screen leading me to believe that the layout itself is not loaded. Below is the activity code.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
String authReqResponse;
Toast errorDisplayToast = new Toast(this);
AuthorizationRequest authReq = new AuthorizationRequest();
authReq.execute(new Void[] {});
try {
authReqResponse = authReq.get();
if(authReqResponse.equalsIgnoreCase(GeneralConstants.AUTH_FAILED_ERROR)) {
errorDisplayToast.makeText(SplashScreen.this, R.string.request_auth_failed_error_message, Toast.LENGTH_LONG);
errorDisplayToast.show();
} else if(authReqResponse.equalsIgnoreCase(null)) {
errorDisplayToast.makeText(SplashScreen.this, R.string.networkErrorMessage, Toast.LENGTH_LONG);
errorDisplayToast.show();
} else {
GeneralConstants.REQ_TOKEN = authReqResponse;
Intent startARIntent = new Intent(SplashScreen.this, MainActivity.class);
startActivity(startARIntent);
finish();
}
} catch(Exception e) {
e.printStackTrace();
}
}