With the code below my background image is not showing in my launchscreen's activity. I have also a thread with a sleep of three seconds but I see only white screen as background. After the delay, I redirect to another activity (in OnStart function). Without the redirect I see my image as background. How can I see my launchscreen image before I redirect to my second activity?
Thanks in advance for the help.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mContext = this;
mAuth = FirebaseAuth.getInstance();
RequestOptions options = new RequestOptions();
options.centerCrop();
RelativeLayout relativeLayout = new RelativeLayout(mContext);
RelativeLayout.LayoutParams relLayoutParam = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
imageView = new ImageView(mContext);
imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
imageView.setBackgroundResource(R.drawable.launch_screen_image);
relativeLayout.addView(imageView, relLayoutParam);
setContentView(relativeLayout, relLayoutParam);
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
@Override
public void onStart() {
super.onStart();
// Check if user is signed in (non-null) and update UI accordingly.
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
FirebaseUser currentUser = mAuth.getCurrentUser();
if (currentUser != null && currentUser.getUid() != null
&& currentUser.getUid().equals(mPrefs.getString("UID", "DEFAULT"))) {
Intent i = new Intent(mContext, SocialPage.class);
startActivity(i);
} else {
Intent i = new Intent(mContext, Login.class);
startActivity(i);
}
}