lfrancatto
lfrancatto

Reputation: 117

Transition of screens

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

Answers (1)

cYrixmorten
cYrixmorten

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

Related Questions