Android如何实现桌面快捷方式
发表于:2025-11-07 作者:千家信息网编辑
千家信息网最后更新 2025年11月07日,这篇文章主要介绍了Android如何实现桌面快捷方式,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。Android 快捷方式使用方式Sh
千家信息网最后更新 2025年11月07日Android如何实现桌面快捷方式
这篇文章主要介绍了Android如何实现桌面快捷方式,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。
Android 快捷方式

使用方式
ShortcutUtils.getInstance().addShortcut(this , MainActivity2.class , liveBundle , "live_Id" , "看直播" , "看直播" , R.drawable.live) .addShortcut(this , MainActivity2.class ,vodBundle , "vod_Id" , "看回放" , "看回放" , R.drawable.vod) .build();
添加权限
ShortcutUtils工具类(直接使用)
/** * Android 快捷方式工具类 * Build.VERSION.SDK_INT >= 25 * API25以上可用 * setShortLabel 设置短标题 * setLongLabel 设置长标题 * setIcon 设置icon * setIntent 设置Intent * @author renquan * @date 2021年12月27日 */public class ShortcutUtils { private static ShortcutUtils shortcutUtils; private List shortcutInfos; private Context mContext; public static ShortcutUtils getInstance() { if (shortcutUtils == null) { synchronized (ShortcutUtils.class) { if (shortcutUtils == null) { shortcutUtils = new ShortcutUtils(); } } } return shortcutUtils; } private ShortcutUtils() { shortcutInfos = new ArrayList<>(); } /** * 设置Class对象 * 所有参数不能为空 * @param context * @param cls * @param bundle * @param shortcutId * @param shortLabel * @param longLabel * @param resId * @return */ public ShortcutUtils addShortcut(Context context, Class> cls, Bundle bundle, String shortcutId, String shortLabel, String longLabel, @DrawableRes int resId) { if (shortcutUtils != null && shortcutInfos != null) { if (Build.VERSION.SDK_INT >= 25) { mContext = context; Intent intent = new Intent(context, cls); intent.putExtra("shortcutArgument", bundle); intent.setAction(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); ShortcutInfo shortcutInfo = new ShortcutInfo.Builder(context, shortcutId) .setShortLabel(shortLabel) .setLongLabel(longLabel) .setIcon(Icon.createWithResource(context, resId)) .setIntent(intent) .build(); shortcutInfos.add(shortcutInfo); } } return shortcutUtils; } /** * 设置Intent对象 * 所有参数不能为空 * @param context * @param intent * @param shortcutId * @param shortLabel * @param longLabel * @param resId * @return */ public ShortcutUtils addShortcut(Context context, Intent intent, String shortcutId, String shortLabel, String longLabel, @DrawableRes int resId) { if (Build.VERSION.SDK_INT >= 25) { mContext = context; if (shortcutUtils != null && shortcutInfos != null) { ShortcutInfo shortcutInfo = new ShortcutInfo.Builder(context, shortcutId) .setShortLabel(shortLabel) .setLongLabel(longLabel) .setIcon(Icon.createWithResource(context, resId)) .setIntent(intent) .build(); shortcutInfos.add(shortcutInfo); } } return shortcutUtils; } /** * 构建Shortcuts */ public void build() { if (shortcutInfos != null && shortcutInfos.size() > 0 && mContext != null) { ShortcutManager systemService = mContext.getSystemService(ShortcutManager.class); systemService.setDynamicShortcuts(shortcutInfos); } }} 感谢你能够认真阅读完这篇文章,希望小编分享的"Android如何实现桌面快捷方式"这篇文章对大家有帮助,同时也希望大家多多支持,关注行业资讯频道,更多相关知识等着你来学习!
方式
篇文章
桌面
参数
对象
工具
标题
直播
价值
兴趣
同时
更多
朋友
权限
知识
编带
行业
资讯
资讯频道
频道
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
为什么会读取服务器超时
临朐租房软件开发
王者荣耀人物转移服务器
arma3服务器游戏进不去
苏州戴尔服务器哪里买
appzao的软件开发者
h2数据库日志文件
怎么用云服务器搭建视频app
软件开发导论课程
数据库导入超时
某大项目包括软件开发子项目
服务器和工控机区别
北京智慧门禁软件开发中心
主从数据库如何读写锁
服务器ip地址和网址关系
jsp封装数据库连接
如何在命令行开启数据库
软件开发用户需求规格说明书
服务器如何租用网络安全
车载网络技术目的
中移在线软件开发待遇
医院安全网络安全隐患排查表
网络安全警告清单
基于lsm的数据库
钉钉数据库怎么找
寻找软件开发工作
数据库原理及应用教程习题第4版
离岸服务器定制
网络运营违反网络安全法的规定
游戏软件开发策划工资