安卓创建快捷图标的代码
2015-07-09 13:39
246 查看
<span style="font-size:24px;">//发送广播的意图, 大吼一声告诉桌面,要创建快捷图标了 Intent intent = new Intent(); intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); //快捷方式 要包含3个重要的信息 1,名称 2.图标 3.干什么事情 intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "手机小卫士"); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher)); //桌面点击图标对应的意图。 Intent shortcutIntent = new Intent(); shortcutIntent.setAction("android.intent.action.MAIN"); shortcutIntent.addCategory("android.intent.category.LAUNCHER"); //第二个参数是当点击这个快捷图标的时候要启动那个页面的全类名 shortcutIntent.setClassName(getPackageName(), "com.itheima.mobilesafe.SplashActivity"); // shortcutIntent.setAction("com.itheima.xxxx"); // shortcutIntent.addCategory(Intent.CATEGORY_DEFAULT); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); sendBroadcast(intent);</span>
相关文章推荐
- Java socket
- 你所不知道的Google广告阴暗面
- 丁林松老师的QT视频及教程源码,讲解比较基础适合新手
- 明明白白学通C语言(二维码版)
- 明明白白学通C语言(二维码版)
- 窗口最大化、最小化以及全屏显示
- 【翻译】《Java™ I/O, 2nd Edition》-14.0 前言
- ThinkPHP_phpmailer使用外部认证SMTP发送邮件
- 基于无向图且权重单一的最短路径Dijkstra算法——JAVA实现
- python中是按值传递参数还是按引用传递参数
- maven+springMVC+mybatis+junit详细搭建过程
- 30第二建筑Github Page
- c语言 交换2个数的值
- python 加密解密(base64, AES)
- Xcode中 #include 搜索顺序
- struts2 在服务器上部署出现的 Dispatcher initialization failed
- Python
- python,tonardo模板中for循环,获取index
- C++ cin.get() 函数重载
- 安卓安装一个程序的代码