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

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

        

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...