【发布时间】:2013-08-29 13:30:06
【问题描述】:
我已经通过以下代码创建了一个 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 这样的 Activity 中,然后我切换到主屏幕并单击快捷方式,应用程序像上面的代码一样来到 MainActivity,我可以避免这种情况并让应用程序如果它已经创建,则进入前台?
【问题讨论】:
标签: android shortcut launchmode