在Android上安裝時,它不會在主屏幕上添加快捷方式,但該應用程序用於。您現在只能在應用程序抽屜中找到它。如何在家庭安卓屏幕上添加應用程序的圖標?如何在家庭安卓屏幕上添加應用圖標(react-native)?
1
A
回答
0
private void removeShortcut() {
Intent shortcutIntent = new Intent(getApplicationContext(),
MainActivity.class);
shortcutIntent.setAction(Intent.ACTION_MAIN);
Intent addIntent = new Intent();
addIntent
.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "HelloWorldShortcut");
addIntent
.setAction("com.android.launcher.action.UNINSTALL_SHORTCUT");
getApplicationContext().sendBroadcast(addIntent);
}
+0
請解釋這個回答有點:)。代碼只有答案大多沒有太大的價值。謝謝你!保持良好的工作! –
+0
我需要添加此代碼的位置? (我不知道java,我正在使用react-native) – Maksim
0
private void addShortcut() {
Intent shortcutIntent = new Intent(getApplicationContext(), MainActivity.class);
shortcutIntent.setAction(Intent.ACTION_MAIN);
Intent addIntent = new Intent();
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "HelloWorldShortcut");
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext(getApplicationContext(), R.drawable.ic_launcher);
addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
getApplicationContext().sendBroadcast(addIntent);
}
相關問題
- 1. 設置家庭(主)屏幕上的應用程序圖標默認
- 2. 安卓:連接到家庭服務器的家庭WiFi
- 3. 如何添加家庭地圖到我的iPhone應用程序?
- 4. 創建在屏幕上點擊(安卓)
- 5. 在屏幕底部添加圖標
- 6. 在AIR應用程序安裝屏幕上顯示圖標
- 7. 如何在屏幕上添加UIToolbar?
- 8. 在全屏幕圖形上添加JComponent
- 9. 在登錄屏幕上添加圖像
- 10. 安卓配件屏幕
- 11. 安卓縮放屏幕
- 12. 安卓屏幕類別
- 13. 如何在主屏幕和子屏幕上添加頁碼
- 14. 如何修改pentaho bi服務器家庭和登錄屏幕
- 15. 安卓視圖項目不固定在屏幕上
- 16. 安卓:人像圖像不是在整個屏幕上
- 17. 安卓:添加啓動圖標編程
- 18. 如何在Android應用程序的開始屏幕上添加徽標?
- 19. 如何在安裝應用程序時自動添加應用程序啓動器圖標到主屏幕(安卓)
- 20. ReactNative抽屜:空白屏幕
- 21. 如何將標籤添加到小部件屏幕圖標?
- 22. 如何在Android中調用「添加到家庭」活動?
- 23. 將圖標添加到主屏幕上,例如Safari
- 24. 如何增加屏幕的Android(安卓工作室設備)
- 25. 禁用自動旋轉屏幕 - 安卓
- 26. 在Android中如何在屏幕上添加特定x-y座標的視圖
- 27. 部分在屏幕底部(安卓)
- 28. 安卓:色調屏幕在圖形頁面(谷歌地圖)
- 29. ReactNative ipa在Splash屏幕後崩潰
- 30. 在主屏幕上添加的網站圖標上顯示標準徽章
一些黑客可以工作,但沒有在Android上做這個沒有直接的方法....但隨意使用android.intent.action.CREATE_SHORTCUT – Selvin