()一:

Android 7.1 增加了很多新特性,比如多窗口,App Shotcuts….

其中,App Shoutcuts就类似于iphone手机上3D Touch功能,在应用桌面长按某个app图标,就会对应的弹出选项,使我们操作更加方便和快速;

先来张图看看安卓的App Shotcuts长什么样:

图片引用官网,长按短信图标弹出的选项。

二:

自己实践为自己的app添加App Shortcuts功能,前提条件必须是android 7.1,api 25

App ShortCuts 实现有两种:

1,xml 布局

2,代码实现

先来讲xml布局实现:

1.首先在自己的清单文件(activity 主入口)下,加入一个 标签

2.然后再res目录下新建一个xml文件夹,随后创建一个xml文件,取名就是上面的引用

android:shortcutId="add_website" //id

android:icon="@drawable/ic_launcher" //图标

android:shortcutShortLabel="@string/shortcuts"

android:shortcutLongLabel="@string/shortcutss" //名字

>

android:action="com.example.android.appshortcuts.ADD_WEBSITE"

android:targetPackage="com.example.administrator.myapplication" //包名

android:targetClass="com.example.administrator.myapplication.MainActivity" //类名

/>

3.到这一步,基本上就已经完成了App Shortcuts的功能,然后打开7.1模拟器run

4.这样就可以了,如果想添加多个选项,怎么办?依然在xml文件中修改(注意,shortcutiId不要一样)

android:shortcutId="add_website"

android:icon="@drawable/ic_launcher"

android:shortcutShortLabel="@string/shortcuts"

android:shortcutLongLabel="@string/shortcutss"

>

android:action="com.example.android.appshortcuts.ADD_WEBSITE"

android:targetPackage="com.example.administrator.myapplication"

android:targetClass="com.example.administrator.myapplication.MainActivity"

/>

android:shortcutId="add_website1"

android:icon="@drawable/ic_launcher"

android:shortcutShortLabel="@string/shortcuts"

android:shortcutLongLabel="@string/shortcutss"

>

android:action="com.example.android.appshortcuts.ADD_WEBSITE"

android:targetPackage="com.example.administrator.myapplication"

android:targetClass="com.example.administrator.myapplication.MainActivity"

/>

android:shortcutId="add_website2"

android:icon="@drawable/ic_launcher"

android:shortcutShortLabel="@string/shortcuts"

android:shortcutLongLabel="@string/shortcutss"

>

android:action="com.example.android.appshortcuts.ADD_WEBSITE"

android:targetPackage="com.example.administrator.myapplication"

android:targetClass="com.example.administrator.myapplication.MainActivity"

/>

如下图:

三:

如果代码实现?其实也很简单,如下

ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);

ShortcutInfo shortcut = new ShortcutInfo.Builder(this, "id1")

.setShortLabel("Web site")

.setLongLabel("Open the web site")

.setIcon(Icon.createWithResource(context, R.drawable.icon_website))

.setIntent(new Intent(Intent.ACTION_VIEW,

Uri.parse("https://www.mysite.example.com/")))

.build();

shortcutManager.setDynamicShortcuts(Arrays.asList(shortcut));

android7.1 shotcuts,Android N App Shotcuts 学习相关推荐

  1. ESP8266 WIFI模块学习之路(7)——自写Android手机APP接受单片机数据

    上一篇是写关于自写Android手机APP给单片机下发数据的,这次我将写一下APP如何接受单片机数据. 其实使用调试助手,或者别人开的的APP同样能够实现接受单片机数据,但想学习的,我还是建议能够自己 ...

  2. 【无人机学习之QGroundControl】android端App初解4-遥控器通道

    █ [无人机学习之QGroundControl]android端App初解4-遥控器通道 █ 系列文章目录 提示:这里是收集了无人机的相关文章 [无人机学习]无人机基础知识 [无人机学习]Missio ...

  3. Android App开发学习第十四天:RecyclerView的简单使用

    简介 RecyclerView 可以用来替代ListView和GridView 应用流程 1.导入相关依赖 进入project structure 添加依赖 2.设计UI界面和item样式 activ ...

  4. Android N App分屏模式完全解析

    Android N App分屏模式完全解析(上) 发表于 2016-03-12 |  分类于 技术 | 上手了Android N Preview,第一个不能错过的新特性就是App分屏的支持.Andro ...

  5. Android 开源项目及其学习

    Android 系统研究:http://blog.csdn.net/luoshengyang/article/details/8923485 Android 腾讯技术人员博客 http://hukai ...

  6. Android接口和框架学习

    Android接口和框架学习 缩写: HAL:HardwareAbstraction Layer,硬件抽象层 CTS:CompatibilityTest Suite,兼容性测试套件 Android让你 ...

  7. app开发学习需要经历哪些流程

    app开发学习需要经历哪些流程?如何零基础入门app开发?以下是知乎热心开发者的经验总结,对学习app开发有很好的参考意义 1.如果没有编程基础的,学习基础知识的过程肯定是必须的. 2.有了一些基础之 ...

  8. Android手机app的adb命令测试电量

    Android手机app电量测试 Android 5.0及以上的设备, 允许我们通过adb命令dump出电量使用统计信息 第一步:手机安装要测试的应用,打开手机开发者模式-USB模式,运行cmd.ex ...

  9. Android 天气APP(三十四)语音搜索

    上一篇:Android 天气APP(三十三)语音播报 语音搜索 前言 正文 一.权限配置 二.用户体验优化 三.配置语音识别听写 四.语音搜索 五.地图天气添加语音搜索功能 六.城市搜索添加语音搜索功 ...

最新文章

  1. 解决ubuntu上opengl的问题
  2. 如何释放指针又不影响内存数据_C# 内存机制 - 基础篇
  3. Atcoder Grand 011 C - Squared Graph
  4. Linux缓冲区溢出问题
  5. linux卸载minicom,ubuntu下minicom超级终端的使用方法
  6. python 获取字符串中的字典_python cookies提取——从字符串到字典(一行Python代码)...
  7. kafka php 教程,php的kafka踩坑(一)
  8. 如何获取网页付费隐藏链接_如何将SEO变成可衡量的收入来源
  9. [JavaWeb基础] 015.Struts2 表单验证框架
  10. mysql怎么删除父行_PHP MySQL删除父行和子行
  11. Java equalsIgnoreCase() 方法
  12. php搭建h5商城,关于PHP的H5商城网站开发方案
  13. Linux系统下安装USB无线网卡驱动方法
  14. 浏览器兼容性问题解决方案 · 总结
  15. MATLAB导出矢量图
  16. Day05 郝斌C语言自学视频之C语言的函数
  17. 基于第三方QQ授权登录
  18. 【vs】 试图加载格式不正确的程序
  19. python 语义similarity_GitHub - samelltiger/word_similarity: 基于《知网》的语义相似度计算 python2.7 API...
  20. php odbc informix,odbc php informix 问题求助

热门文章

  1. cdn与服务器的关系_掐指算算: 你的CDN多花了几百万?
  2. 为什么虚拟机的linux系统IP是10.0.2.15
  3. 数据埋点太难!知乎的做法有何可借鉴之处?
  4. 如何提升springboot服务吞吐量
  5. 面试官如何考察你的思维方式?【比较有趣】
  6. 手绘风格的数据可视化 (萌萌风)Sketchify,及其他可视化工具(商业风)
  7. Hadoop 06_MapReduce2.0(YARN)
  8. 解决idea maven的导入依赖过慢
  9. 【EasyUI】DataGrid 合并单元格 - 使用实例
  10. 【Git】撤销已经git add的文件