代码                                                                                   

/**
*
* 返回添加到桌面快捷方式的Intent:
*
* 1.给Intent指定action="com.android.launcher.INSTALL_SHORTCUT"
*
* 2.给定义为Intent.EXTRA_SHORTCUT_INENT的Intent设置与安装时一致的action(必须要有)
*
* 3.添加权限:com.android.launcher.permission.INSTALL_SHORTCUT
*/ public Intent getShortcutToDesktopIntent(Context context) {
Intent intent = new Intent();
intent.setClass(context, context.getClass());
/* 以下两句是为了在卸载应用的时候同时删除桌面快捷方式 */
intent.setAction("android.intent.action.MAIN");
intent.addCategory("android.intent.category.LAUNCHER"); Intent shortcut = new Intent(
"com.android.launcher.action.INSTALL_SHORTCUT");
// 不允许重建
shortcut.putExtra("duplicate", false);
// 设置名字
// shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,context.getString(R.string.app_name));
shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, "11111");
// 设置图标
shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext(context,
R.drawable.youtube));
// 设置意图和快捷方式关联程序
shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent); return shortcut;
}

权限                                                                                   

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

调用                                                                                   

public void click1(View v) {
Intent intent = this.getShortcutToDesktopIntent(MainActivity.this);
sendBroadcast(intent);
}

我是天王盖地虎的分割线                                                             

Android -- 创建桌面快捷方式的更多相关文章

  1. Android创建桌面快捷方式

    在桌面上创建特定界面的快捷入口,icon和title根据请求参数命名.在网上收集的一些相关资 料,在使用intent发送广播的时候,一些型号的收集会有问题,如魅族MX,红米,以及华为,使用setCla ...

  2. (转)Android创建桌面快捷方式两种方法

    [IT168技术]Android在桌面上生成快捷方式有两种情况,一种是直接在桌面直接生成;一种是长按桌面,在弹出的快捷菜单中生成. 谈谈在桌面上直接生成.个人觉得这个比较爽快,既然都是快捷方式了干嘛还 ...

  3. android创建桌面快捷方式(启动目标非项目的启动页)

    1.布局文件中,目标Activity加入以下filter <intent-filter>                  <action android:name="an ...

  4. Android开发之创建桌面快捷方式

    Android创建桌面快捷方式就是在桌面这个应用上创建一个快捷方式,桌面应用:launcher2 通过查看launcher2的清单文件: <!-- Intent received used to ...

  5. android 为应用程序创建桌面快捷方式技巧分享

    手机装的软件过多,找起来很不方便,所以在主页面有一个快捷方式的话会很不错的,本文将介绍如何实现,需要了解跟多的朋友可以参考下     我们开发一款软件后,如果手机装的软件过多,去翻的话会很难翻的,所以 ...

  6. Android 添加桌面快捷方式操作

    /** * 为程序创建桌面快捷方式 */ private void addShortcut(){ Intent shortcut = new Intent(“com.android.launcher. ...

  7. Android创建桌面快捷图标

    <!-- 添加快捷方式 --> <uses-permission android:name="com.android.launcher.permission.INSTALL ...

  8. Ubuntu创建桌面快捷方式

    默认情况下,ubuntu会将自动安装的软件快捷方式保存在/usr/share/applications目录下,如果我们要创建桌面快捷方式,只需要右键-复制-桌面 就Ok,如图: 上面的方法是通过系统自 ...

  9. Windows中创建桌面快捷方式

    Windows中创建桌面快捷方式 -------------- -------------- -------------- --------------

随机推荐

  1. 在XML序列化时去除默认命名空间xmlns:xsd和xmlns:xsi

    摘 自: http://blog.csdn.net/fxhflower/article/details/7276820 可使用以下代码: //Create our own namespaces for ...

  2. sotower1.5报错 -Xlint:unchecked

    新建sotower项目 控制台启动正常,登录页面报错 StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw except ...

  3. if [-f build/core/envsetup.mk -a -f Makefile ]; then

    这个语法是什么意思?

  4. Javascript 常用系统内置函数

    1:在数组指定位置插入元素 array.splice(2, 0, "three");   //在索引2的位置,删除0个元素后,插入元素“three” 例子: // 原来的数组 va ...

  5. 查看cics 运行状态

     查看cics 运行状态cicscp -v status all 

  6. DPDK内存管理-----(二)rte_mempool内存管理

    DPDK以两种方式对外提供内存管理方法,一个是rte_mempool,主要用于网卡数据包的收发:一个是rte_malloc,主要为应用程序提供内存使用接口.本文讨论rte_mempool.rte_me ...

  7. HTML表单的问题

    1. 表单一定要放在<form>标签里面,就会有错误. 像<textarea>单独放的时候,单击的时候不会出现在开始位置,而是在任意单击的地方开始.  

  8. jquery click & get value of attributes of a href

    http://stackoverflow.com/questions/6625667/jquery-click-get-value-of-attributes-of-a-href /* Add a l ...

  9. String类的比较

    //strcmp只能运用于数组的比较 //string类可以用成员函数compare() //即a.compare(b) //例如 "; "; a.compare(b)返回值= & ...

  10. delphi 基础之三 文件流操作

    文件流操作 Delphi操作流文件:什么是流?流,简单来说就是建立在面向对象基础上的一种抽象的处理数据的工具.在流中,定义了一些处理数据的基本操作,如读取数据,写入数据等,程序员是对流进行所有操作的, ...