代码                                                                                   

/**
*
* 返回添加到桌面快捷方式的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. iTunes - Forensic guys' best friend

    What chances do you think to acquire suspect's data from his/her iDevice? If suspects also use iTune ...

  2. poj2070

    #include <stdio.h> int main(){ double a,b,c; int s; while(~scanf("%lf%lf%lf",&a, ...

  3. 理解CSS中BFC

    BFC(Block Formatting Context) 是Web页面中盒模型布局的CSS渲染模式.它的定位体系 属于 常规文档流 .摘自 W3C : 浮动,绝对定位元素, inline-block ...

  4. js,jquery获取下拉框选中的option

    js获取select选中的值: var sel=document.getElementById("select1"); var index = sel.selectedIndex; ...

  5. kickstart简介 20140707

    kickstart是红帽发行版中的一种安装方式,它通过以配置文件的方式来记录linux系统安装是的各项参数和想要安装的软件.只要配置正确, 整个安装过程中无需人工交互参与,达到无人值守安装的目的,因而 ...

  6. ThinkPHP5中Session的使用

    由于用惯了ThinkPHP之前的版本,一想到要用Session就直接用$_SESSION来存取,今天看了ThinkPHP5的手册,才发现原来这么用时不安全滴.ThinKPHP5对Session进行了封 ...

  7. Java调第三方的webservice接口

    1.eclipse中add dynamic web project 2.选中项目右键new——> webservice ——> webservice client 在service def ...

  8. 发送Ajax请求获取JSON格式数据

    Aspx前端页面: <script type="text/javascript"> $(function () { $.getJSON("Ajax/TestA ...

  9. 设置field的背景颜色以及对stylesheet的理解

    今天遇到一个需求:在做页面输入验证的时候,如果用户没有输入某个项,那么这个项显示为红色,一直没头绪,也找peoplebook,发现field有一个style的方法,后来又在谷歌上找,终于找到了方法: ...

  10. "/Date(1405056837780)/" 时间转换

    //往往json传过来的时间都是"/Date(1405056837780)/" //转换需要的方法 String.prototype.ToString = function (fo ...