java - 如何以编程方式生成图标并使用它而不是快捷方式图标?
问题描述
有没有办法以编程方式生成图标(恒定背景和中心文本(来自可以更改的变量))并使用它而不是快捷方式图标?
解决方案
看起来 Android 的 ShortcutManager 可能最适合您的需求,因为它允许静态和动态生成快捷方式。 https://developer.android.com/guide/topics/ui/shortcuts.html#dynamic
ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
ShortcutInfo shortcut = new ShortcutInfo.Builder(this, SHORTCUT_ID)
.setShortLabel("My Shortcut")
.setLongLabel("This is my shortcut")
.setIcon(Icon.createWithResource(context, R.drawable.mipmap))
.setIntent(SHORTCUT_ACTION)
.build();
shortcutManager.setDynamicShortcuts(Arrays.asList(shortcut));
推荐阅读
- python - import 语句的正确语法
- angular - 如何将数据发送到嵌套组件(父子(父)子)?
- reactjs - 如何在 React 中实现 PWA,以便我的应用程序可以离线工作
- python - Python xml-rpc tcp 持久连接
- c++ - 将“提取器”传递给也采用可迭代对象的 C++ 方法
- azure - SELECT VALUE COUNT(1) FROM (SELECT DISTINCT c.UserId FROM root c) AS t not working
- python - 为什么我需要使用异步工具来发送 Django 电子邮件
- sql-server - 为多个字段创建同义词(或类似)
- python - Python 线程:线程运行两次?
- javascript - 数组存储与输入不同的数字