Android 7.1 Shortcuts功能
来源:互联网 发布:万网域名绑定非80端口 编辑:程序博客网 时间:2024/05/22 00:20
Android 7.1发布已久,是时候来了解一下Android 7.1新特性了,接下来将讲述Android 7.1的Shortcuts(快捷方式)。
创建快捷方式的方法有两种:静态方式与动态方式
1、静态方式创建
1.1 创建一个res/xml/shortcuts.xml布局
<?xml version="1.0" encoding="utf-8"?><shortcuts xmlns:android="http://schemas.android.com/apk/res/android"> <shortcut android:shortcutId="short_1" android:enabled="true" android:shortcutShortLabel="@string/shortcut_short_1" android:shortcutLongLabel="@string/shortcut_long_1" android:shortcutDisabledMessage="@string/shortcut_disabled_1"> <intent android:action="android.intent.action.View" android:targetPackage="com.app.helloworld" android:targetClass="com.app.helloworld.SecActivity"/> </shortcut> <shortcut android:shortcutId="short_2" android:enabled="true" android:shortcutShortLabel="@string/shortcut_short_2" android:shortcutLongLabel="@string/shortcut_long_2" android:shortcutDisabledMessage="@string/shortcut_disabled_2"> <intent android:action="android.intent.action.Main" android:targetPackage="com.app.helloworld" android:targetClass="com.app.helloworld.MainActivity"/> <intent android:action="android.intent.action.View" android:targetPackage="com.app.helloworld" android:targetClass="com.app.helloworld.ThirdActivity"/> /> </shortcut></shortcuts>
1.2 在AndroidManifest.xml文件中申明shortcut位置,特别注意下面代码申明需放在第一个Activity的申明中,否则无效:
<activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <meta-data android:name="android.app.shortcuts" android:resource="@xml/shortcuts" /> </activity>
如此,就大功告成了!!!
2、动态态方式创建
// Shortcut管理类 ShortcutManager manager = getSystemService(ShortcutManager.class); Intent intent1 = new Intent(this,SecActivity.class); intent1.setAction("android.intent.action.View"); /* * 默认显示LongLabel * LongLabel文本过长时,显示ShortLabel * Shortcut不能用时,显示DisabledMessage * Rank下标,用于排序 */ ShortcutInfo shortcut_1 = new ShortcutInfo.Builder(this,"shortcut_1") .setShortLabel("Short 1") .setLongLabel("Short Long 1") .setDisabledMessage("Short Disabled Message") .setIntent(intent1) .setRank(0) .build(); Intent intent2 = new Intent(this,ThirdActivity.class); intent2.setAction("android.intent.action.View"); ShortcutInfo shortcut_2 = new ShortcutInfo.Builder(this,"shortcut_2") .setShortLabel("Short 2") .setLongLabel("Short Long 2") .setDisabledMessage("Short Disabled Message 2") .setIntent(intent2) .setRank(1) .build(); manager.addDynamicShortcuts(Arrays.asList(shortcut_1,shortcut_2));
源码地址:http://download.csdn.net/download/y472360651/9819418
0 0
- Android 7.1 Shortcuts功能
- Android 7.1 快捷方式 Shortcuts
- android 7.1快捷方式App Shortcuts
- Android 7.1 App Shortcuts使用
- Android 7.1 App Shortcuts使用
- 探索Android 7.1 app快捷方式(App Shortcuts)
- Android 7.1 新特性之 Shortcuts运用
- Android N_MR1(7.1) App Shortcuts简单使用
- Android基础知识---7.1新特性:Shortcuts详解
- Android 7.1 新特性:快捷方式 Shortcuts 详解
- Android Studio Shortcuts
- Android ShortCuts使用
- App Shortcuts (android25,7.1)
- Android开发之Shortcuts, LiveFolder, Widget
- Android studio1.2 shortCuts 小白使用
- 拥抱Android O,Android固定快捷方式App Shortcuts
- Android ApiDemos示例解析(24):App->Launcher Shortcuts
- Android ApiDemos示例解析(24):App->Launcher Shortcuts
- 2016湘潭邀请赛 XTU 1243 2016
- Android---网络请求
- 新版chrome调整开发者工具位置方式改变
- 聊一聊web应用对象:ServletContext
- 从命令行程序学习Objective-C的类和函数
- Android 7.1 Shortcuts功能
- Winner-take-all Autoencoder
- 代理模式之继承式静态代理
- SourceInsight Macro编程-1
- java中finally的执行顺序
- Fragment中使用工具栏总结
- The KITTI Vision Benchmark Suite之Sensor Setup篇章
- 【IMWeb训练营作业】To do list
- Linux内核学习总结