5
我想知道是否有一個選項可以在安裝後在用戶的桌面上設置我的應用程序的自動圖標鏈接?桌面圖標鏈接
我知道這樣做的唯一方法是用戶可以從應用程序列表中手動拖動到他的桌面。有沒有辦法自動爲用戶做(無需他的觸摸)?
謝謝,
Moshic。
我想知道是否有一個選項可以在安裝後在用戶的桌面上設置我的應用程序的自動圖標鏈接?桌面圖標鏈接
我知道這樣做的唯一方法是用戶可以從應用程序列表中手動拖動到他的桌面。有沒有辦法自動爲用戶做(無需他的觸摸)?
謝謝,
Moshic。
請不要這樣做自動! 讓用戶選擇是否他想要你的捷徑!
以下是你需要的代碼:
//Create shortcutIntent here with the intent that will launch you app.
Intent shortcutIntent = (...)
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,sName);
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, icon);
// add the shortcut
intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
sendBroadcast(intent);
不要忘記在清單額外的許可!
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
當用戶安裝應用程序時是否可以自動執行此操作? – Moshik 2010-07-26 10:43:09
我從來沒有聽說過自推出的應用程序在Android ... 您可以在第一次手動啓動應用程序時執行這段代碼。 – 2010-07-26 10:45:45
我爲我的應用程序做的是創建布爾首選項「actiondone」,即默認爲「false」 如果(!actiondone) 那麼我將此首選項設置爲true,並進行我的「firstboot」操作。 希望您熟悉偏好... – 2010-07-26 13:09:50