Automatic start of a new activity in android

后端 未结 2 1928
轮回少年
轮回少年 2021-02-09 14:36

I am creating an android application. I have a logo screen(Activity) and then my home screen(another activity). I want that when I start my application

2条回答
  •  长发绾君心
    2021-02-09 15:07

    Please use this..

    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.os.Handler;
    
    public class Logo extends Activity {
    protected boolean _active = true;
    protected int _splashTime = 2000;
    
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.logo);
    
        Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            public void run() {
                finish();
                Intent i3 = new Intent(Logo.this, Home.class);
                    startActivity(i3);
            }
        }, _splashTime);
    }
    }
    

提交回复
热议问题