Android -- ShortCut
添加
添加快捷方式是向桌面应用(launcher)发送相关action的广播:
public static final String ACTION_ADD_SHORTCUT = "com.android.launcher.action.INSTALL_SHORTCUT";
Code:
private void addShortcut(String name) {
Intent addShortcutIntent = new Intent(ACTION_ADD_SHORTCUT);
// 不允许重复创建
addShortcutIntent.putExtra("duplicate", false);// 经测试不是根据快捷方式的名字判断重复的
// 名字
addShortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, name); // 图标
addShortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext(MainActivity.this,
R.drawable.ic_launcher)); // 设置关联程序
Intent launcherIntent = new Intent(Intent.ACTION_MAIN);
launcherIntent.setClass(MainActivity.this, MainActivity.class);
launcherIntent.addCategory(Intent.CATEGORY_LAUNCHER); addShortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, launcherIntent); // 发送广播
sendBroadcast(addShortcutIntent);
}
移除
action:
public static final String ACTION_REMOVE_SHORTCUT = "com.android.launcher.action.UNINSTALL_SHORTCUT";
Code:
private void removeShortcut(String name) {
Intent intent = new Intent(ACTION_REMOVE_SHORTCUT);
// 名字
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, name);
// 设置关联程序
Intent launcherIntent = new Intent(MainActivity.this,MainActivity.class).setAction(Intent.ACTION_MAIN);
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, launcherIntent);
// 发送广播
sendBroadcast(intent);
}
权限
<!-- 添加快捷方式 -->
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<!-- 移除快捷方式 -->
<uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" />
我是天王盖地虎的分割线
Android -- ShortCut的更多相关文章
- android shortcut &livefoulder
android shortcut(实现步骤) 1.建立activity 2.minifest 里面注册并加上intent-filter,name为:android.intent.action.CREA ...
- Android 7.1 - App Shortcuts
Android 7.1 - App Shortcuts 版权声明:本文为博主原创文章,未经博主允许不得转载. 微博:厉圣杰 源码:AndroidDemo/Shortcuts 文中如有纰漏,欢迎大家留言 ...
- Android 7.1 App Shortcuts使用
Android 7.1 App Shortcuts使用 Android 7.1已经发了预览版, 这里是API Overview: API overview. 其中App Shortcuts是新提供的一 ...
- 安卓7.1 新特性Shortcut
介绍 Shortcut 是谷歌在API25提出来的 类似苹果3D touch 但是没有压力感应.在安卓中完全就是长按. 来看下效果吧: 是不是很赞? 那么请随本文一起学习吧 更新 新建项目 在你项目下 ...
- Android 7.1.1 之实现 3D Touch
转载请注明出处:http://blog.csdn.net/yyh352091626/article/details/68962736 Shortcut概念 详细实现 BuildConfig 配置 静态 ...
- Android 7.1 快捷方式 Shortcuts
转载请注明出处:王亟亟的大牛之路 前些天就看到相关内容了,但是最近吸毒比较深(wow),所以没有紧跟潮流,今天补一篇. 先安利:https://github.com/ddwhan0123/Useful ...
- android7/8新特性 画中画、shortcut和分屏模式
多窗口 在android7.0中原生提供了多窗口模式和画中画模式,多窗口模式将屏幕分为上下或左右两块区域分别显示两个应用,画中画模式主要应用在android TV中,类似于windows中的多窗口. ...
- App Shortcuts 快捷方式:Android 的 '3D Touch'
Hello Shortcuts 从Android7.1(API level25)开始,开发者可以为自己的app定制shortcuts.shortcuts使用户更便捷.快速的使用app.我个人感觉有点像 ...
- Android添加快捷方式(Shortcut)到手机桌面
Android添加快捷方式(Short)到手机桌面 权限 要在手机桌面上添加快捷方式,首先需要在manifest中添加权限. <!-- 添加快捷方式 --> <uses-permis ...
随机推荐
- Oracle 默认的几个登陆用户名和密码
默认用户有这么几个,system,sys,scott,hr ,一般scott 和hr 作为你的练习用户.system的默认密码是 manager sys的默认密码是 change_on_install ...
- iOS 11开发教程(三)运行第一个iOS 11程序
iOS 11开发教程(三)运行第一个iOS 11程序 运行iOS11程序 创建好项目之后,就可以运行这个项目中的程序了.单击运行按钮,如果程序没有任何问题的话,会看到如图1.6和1.7的运行效果. 图 ...
- 数据预处理:规范化(Normalize)和二值化(Binarize)
注:本文是人工智能研究网的学习笔记 规范化(Normalization) Normalization: scaling individual to have unit norm 规范化是指,将单个的样 ...
- python开发_configparser_解析.ini配置文件工具_完整版_博主推荐
# # 最近出了一趟差,是从20号去的,今天回来... # 就把最近学习的python内容给大家分享一下... # ''' 在python中,configparser模块提供了操作*.ini配置文件的 ...
- codevs 1191 树轴染色 线段树区间定值,求和
codevs 1191 树轴染色 Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://www.codevs.cn/problem/1191/ Des ...
- spring---transaction(5)---事务的体系
1.写在前面 事务的模型为3中: 本地事务模式. 编程事务模式. 声明事务模式. 例子1:本地事务模式 Connection conn=jdbcDao.getConnection(); Prepare ...
- 丢失或损坏NDF文件如何附加数据库
在论坛看到有人遇到 NDF文件丢失并且没有备份,所以无法成功附加数据库.在网上也看到过很多回答是如果没有NDF就无法附加成功. 其实我自己测试下来即使没有NDF也是可以成功附加的.但是有条件,丢失的N ...
- TASKER 手机在有同一个号码的三个未接电话时自动回复短信
http://tieba.baidu.com/p/3695018030 感谢默默为Tasker吧奉献的人! 配置为>未接来电 任务为>代码>javascriptlet 代码为: va ...
- C#软件license管理(简单软件注册机制)
最近做了一个绿色免安装软件,领导临时要求加个注册机制,不能让现场工程师随意复制.事出突然,只能在现场开发(离开现场软件就不受我们控了).花了不到两个小时实现了简单的注册机制,稍作整理. ...
- hdu 1847 博弈基础题 SG函数 或者规律2种方法
Good Luck in CET-4 Everybody! Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ...