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;
}
}
}
}