我通过以下代码创建了一个 android 快捷方式
Intent 快捷方式 = new Intent("com.android.launcher.action.INSTALL_SHORTCUT"); 快捷方式.putExtra(Intent.EXTRA_SHORTCUT_NAME,getString(R.string.app_name));
意图快捷方式Intent = new Intent();
shortcutIntent.setClassName(this,MainActivity.class.getName());
快捷方式.putExtra(意图.EXTRA_SHORTCUT_INTENT,快捷方式意图);
快捷方式.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
快捷方式.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(this, R.drawable.ic_launcher);
快捷方式.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes);
发送广播(快捷方式);
当我打开我的应用程序,最后在一些像 BActivity 这样的活动中,然后我切换到主屏幕并单击快捷方式,应用程序像上面的代码一样来到 MainActivity,我有机会避免这种情况,只是让应用程序进入前台如果它已经创建?