Android启动图3秒后自动跳转首页

1,本篇博文主要讲解在Android开发之中,合理运行启动图,让移动端程序更加的直观明了。
2,功能分为:

  1. 启动时候的图片以及规格png格式,导入到项目中;
  2. 设定此图片显示为多少秒,然后跳转;
  3. 继承BaseActivity,自动跳转;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import com.dt.R;
import com.dt.base.ui.activity.BaseActivity;

public class WelcomeActivity extends BaseActivity {

    private static final int times = 3000;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.welcome_activity);
    }

    @Override
    protected void onResume() {
        super.onResume();
    }


    @Override
    protected void onStart() {
        super.onStart();
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent intent = new Intent(WelcomeActivity.this,MainActivity.class);
                startActivity(intent);
                overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit);
                finish();
            }
        }, times);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

    }
}

BaseActivity

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.FrameLayout;

import com.dt.utils.ActivityCollector;


/**
 * Created by rnd on 2018/4/8.
 *
 */

public class BaseActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityCollector.addActivity(this);
    }


    public View getContentViews() {
        FrameLayout view = findViewById(android.R.id.content);
        return view.getChildAt(0);
    }

    protected View contentViews;

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ActivityCollector.removeActivity(this);
    }
}

记得配置文件的阐述:

        
            
                
                
                
                
                
            
        

welcome_activity





本章节实现的代码逻辑到此为止,Android启动效果图已检验完毕,上述代码挪用即可。

你可能感兴趣的:(Android)