我有一個應用程序,允許您創建一個特定的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