把这段代码贴到  super.onCreate(savedInstanceState);  之后

 

//remenber process

if(!this.isTaskRoot()) { //判断该Activity是不是任务空间的源Activity,“非”也就是说是被系统重新实例化出来

//如果你就放在launcher Activity中话,这里可以直接return了

                        Intent mainIntent=getIntent(); 

String action=mainIntent.getAction();

if(mainIntent.hasCategory(Intent.CATEGORY_LAUNCHER) && action.equals(Intent.ACTION_MAIN)) {

finish();

return;//finish()之后该活动会继续执行后面的代码,你可以logCat验证,加return避免可能的exception

}

}

相关文章:

  • 2022-12-23
  • 2021-06-19
  • 2021-12-14
  • 2021-10-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-16
  • 2021-11-25
  • 2021-07-25
  • 2022-12-23
  • 2022-12-23
  • 2022-01-22
相关资源
相似解决方案