How to move to another activity in a few seconds?

10,749

Use below Code for that.

Splash_Screen_Activity.java

public class Splash_Screen_Activity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash_screen);

        final Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            public void run() {
                // TODO: Your application init goes here.
                Intent mInHome = new Intent(Splash_Screen_Activity.this, InvoiceASAPTabActivity.class);
                Splash_Screen_Activity.this.startActivity(mInHome);
                Splash_Screen_Activity.this.finish();
            }
        }, 3000);
    }
}
Share:
10,749

Related videos on Youtube

Abhinav
Author by

Abhinav

Updated on September 16, 2022

Comments

  • Abhinav
    Abhinav over 1 year

    I have a splash screen. I just want it to wait for 1 or 2 sec and then move on to the next activity just then once. I understand there are many ways including handler classes and java.util.timer implementation. But which is the easiest and most light way to do just this. Thanx in advance.

  • Abhinav
    Abhinav over 11 years
    Thats what i was talking about. Worked like a charm. Thanx a lot!!