private Handler handler = new Handler(){
    @Override
    public void handleMessage(Message msg) {
        if (msg.what==0){
            Intent intent = new Intent(MainActivity.this, Activity01.class);
            startActivity(intent);

        }else {
            Intent intent = new Intent(MainActivity.this, Activity02.class);
            startActivity(intent);
        }
    }
};
判断第几次进入主页面

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    SharedPreferences preferences = getSharedPreferences("shibian", MODE_PRIVATE);
    boolean b = preferences.getBoolean("name", false);
    if (b){
        handler.sendEmptyMessageDelayed(1,2000);
    }else {
        preferences.edit().putBoolean("name",true).commit();
        handler.sendEmptyMessageDelayed(0,2000);
    }

}

相关文章:

  • 2021-10-17
  • 2022-12-23
  • 2022-12-23
  • 2021-11-24
  • 2022-12-23
  • 2022-12-23
  • 2021-12-07
  • 2022-01-09
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-24
相关资源
相似解决方案