首先我们先展示其代码:

Lauch.java

 android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.view.WindowManager;

public class Launch extends AppCompatActivity {



    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_launch);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getSupportActionBar().hide();
        new Handler().postDelayed(new Runnable(){ // 为了减少代码使用匿名Handler创建一个延时的调用
            public void run() {
                Intent i = new Intent(Launch.this, FirstActivity.class); //通过Intent打开最终真正的主界面的FirstActivity,相当于界面的跳转

        Launch.this.startActivity(i); //启动Main界面

        Launch.this.finish(); //关闭自己这个开场屏 } }, 1000); //1秒,够用了吧,这里是写自己开屏的时间,想写多少写多少。 } }

上述代码还是很好理解的,这段代码用于我们第一个活动的开启,之后我们还需要在manifast文件把这个活动主活动注册成主活动就可以了(重要!!!),因为这是APP开始的第一个活动!

相关文章:

  • 2021-04-02
  • 2022-12-23
  • 2021-12-23
  • 2021-04-24
  • 2021-04-27
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-04-18
  • 2022-12-23
  • 2021-12-12
  • 2021-07-17
  • 2021-05-11
  • 2021-03-26
相关资源
相似解决方案