Android创建桌面快捷图标
2015-10-26 15:25
519 查看
<!-- 添加快捷方式 --> <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" /> <!-- 移除快捷方式 --> <uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" /> <!-- 查询快捷方式 --> <uses-permission android:name="com.android.launcher.permission.READ_SETTINGS" />
添加快捷方式,是向桌面应用(launcher)发送相关action的广播,相关的action如下:
// 创建桌面快捷方式 public void createShortCut(){ //创建快捷方式的Intent Intent shortcutintent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT"); //不允许重复创建 shortcutintent.putExtra("duplicate", false); //需要现实的名称 shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "兴业证券"); //快捷图片 Parcelable icon = Intent.ShortcutIconResource.fromContext(getApplicationContext(), R.drawable.ic_launcher); shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon); //点击快捷图片,运行的程序主入口 shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(getApplicationContext() , splash.class)); //发送广播。OK sendBroadcast(shortcutintent); }
相关文章推荐
- 监听后台Service是否被Kill并重新启动Service
- Android 横竖屏处理
- Android编程实现小说阅读器滑动效果的方法
- Android 绘制虚线
- LeakCanary-Android内存泄露检测
- Android Studio Gradle基础
- android 动画
- 【Android学习笔记】 菜单Menu
- Android编程中TextView宽度过大导致Drawable无法居中问题解决方法
- android studio 断点调试
- android源码 键盘消息处理机制
- Google Breakpad 用VS编译windows和android平台的库文件
- android ImageView scaleType属性
- android 扇形菜单
- android学习——popupWindow 在指定位置上的显示
- android开发之sqlite数据库增删改查
- Android程序启动程序与页面的跳转
- Android 编程下 PopupWindow 窗口的弹出
- Android编程中聊天页面背景图片、标题栏由于键盘引起问题的解决方法
- Android 滑动菜单框架完全解析