gpt4 book ai didi

android - 桌面图标链接

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:50:02 24 4
gpt4 key购买 nike

我想知道是否有一个选项可以在安装后在用户的桌面上设置我的应用程序的自动图标链接?

我知道的唯一方法是用户可以将其从应用程序列表中手动拖到他的桌面上。有没有办法为用户自动执行此操作(无需他的触摸)?

谢谢,

马赛克。

最佳答案

请不要自动这样做!!!让用户选择是否需要您的快捷方式!

这是您需要的代码:

        //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);

不要忘记 list 中的额外权限!

        <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />

关于android - 桌面图标链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3332753/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com