我有一个应用程序,允许您创建一个特定的Activity
首页“快捷方式”。事实证明,我的一些用户将使用该应用程序,点击主键以执行其他操作,然后使用其中一个快捷键跳回该活动。由于该应用程序仍在记忆中,因此只需在其他人的基础上打开新的Activity
,“后退”键将使他们回到整个历史记录。我想要发生的事情是,如果他们使用快捷方式然后有效地杀死历史记录并使后退键退出应用程序。有什么建议么?如何使Android“家庭”快捷方式绕过应用程序,直指历史?
3
A
回答
7
首先,建立taskAffinity的清单,使Activity
运行方式不同的“任务”:
<activity
android:taskAffinity=""
android:name=".IncomingShortcutActivity">
<intent-filter>
<action android:name="com.example.App.Shortcut"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
然后,建立快捷方式时,设置FLAG_ACTIVITY_NEW_TASK
和FLAG_ACTIVITY_CLEAR_TOP
标志。像这样:
// build the shortcut's intents
final Intent shortcutIntent = new Intent();
shortcutIntent.setComponent(new ComponentName(this.getPackageName(), ".IncomingShortcutActivity"));
shortcutIntent.putExtra(EXTRA_STOPID, Integer.toString(this.stop_id));
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
final Intent intent = new Intent();
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
// Sets the custom shortcut's title
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, custom_title);
// Set the custom shortcut icon
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(this, R.drawable.bus_stop_icon));
// add the shortcut
intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
sendBroadcast(intent);
1
尝试将Intent.FLAG_NEW_TASK
添加到意图。
+0
那么,至少让我成为那里的一部分。谢谢 – 2009-06-11 03:00:45
相关问题
- 1. Android的 - 从家庭或历史检测应用程序启动
- 2. 命令历史的Cygwin快捷方式
- 3. 如何关闭新的Android 7.1应用程序快捷方式
- 4. VIM:查找最近使用的快捷方式的历史
- 5. 如何在android中以编程方式添加应用程序快捷方式
- 6. 使用Process.Start通过快捷方式运行应用程序C#
- 7. .net .vdproj - 应用程序快捷方式
- 8. 应用程序快捷方式
- 9. 离线应用程序快捷方式
- 10. 创建应用程序快捷方式
- 11. android设置应用程序快捷方式
- 12. 如何使用适用于android 7.1应用程序的ShortcutManager API创建动态应用程序快捷方式?
- 13. Android应用中的快捷方式
- 14. 如何重新创建webstart应用程序的快捷方式?
- 15. 如何创建Java桌面应用程序的快捷方式?
- 16. 如何在应用程序中实现快捷方式
- 17. 调试历史记录的Eclipse启动快捷方式
- 18. android快捷方式,可以快捷方式intent额外包含应用程序对象吗?
- 19. Chrome应用程序快捷方式/ Mozilla Prism安装程序
- 20. C#VS卸载程序2010-应用程序快捷方式
- 21. 我如何使我的应用程序作为家庭应用程序
- 22. 如何使用WIX创建卸载程序快捷方式
- 23. “快捷方式制造商”和“应用程序快捷方式制造商”如何运作?
- 24. 通过使用Android应用程序的GSM屏蔽的家庭自动化
- 25. 如何以编程方式使用Win32创建快捷方式
- 26. xcode 3.2.1通过键盘快捷方式的文件历史记录
- 27. Chrome应用程序模式 - 禁用快捷方式
- 28. Android,如何运行Chrome快捷方式?
- 29. 如何在应用程序安装后自动创建android应用程序的快捷方式
- 30. Android:我如何在自己的应用程序中启动某个应用程序的快捷方式?
请您澄清一点吗?代码应该去哪里,IncomingShortcutActivity?谁来处理广播? – Maxim 2011-08-08 20:26:25