app首次安装完成后在安装界面直接“打开”应用再按home键返回
2020-10-27 本文已影响0人
wangmf
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(R.style.SplashTheme);
super.onCreate(savedInstanceState);
//首次安装按home键置入后台,从桌面图标点击重新启动的问题
if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) {
finish();
return;
}
if (!isTaskRoot()) {
final Intent intent = getIntent();
final String intentAction = intent.getAction();
if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && intentAction != null && intentAction.equals(Intent
.ACTION_MAIN)) {
finish();
return;
}
}
setContentView(R.layout.view_new_home);
}