Android 在安装完成界面直接打开应用,按HOME回到桌面,再次点击应用图标,会重新走 android.intent.category.LAUNCHER Activity,解决方案如下:
在该Activity的onCreate加入如下代码,
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!this.isTaskRoot()) {
Intent intent = getIntent();
if (intent != null) {
String action = intent.getAction();
if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && Intent.ACTION_MAIN.equals(action)) {
finish();
return;
}
}
}
}