Reputation: 117
I'm trying to create a transition between two screens with the option to sleep, the transition occurs but the splash screen is blank.
Follow the code below:
@ Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_screen1);
try {
Thread.sleep (1000);
Initial intent = new Intent (getApplicationContext (), scren2.class);
startActivity (initial);
} Catch (Exception e) {
e.printStackTrace ();
}
}
Upvotes: 0
Views: 59
Reputation: 7108
Try this
protected void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_screen1);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent initial = new Intent (getApplicationContext (), scren2.class);
startActivity (initial);
}
}, 1000);
}
Upvotes: 1