微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android – 桌面图标链接

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

我知道这样做的唯一方法用户可以从应用程序列表中手动将其拖动到桌面.有没有办法自动用户做这件事(没有他的触摸)?

谢谢,

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

不要忘记清单中的额外许可!

        

原文地址:https://www.jb51.cc/android/430288.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐