private void addChoiceShortcuts() {
ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
if (mChoice.isFinish()) {
shortcutManager.removeAllDynamicShortcuts();
return;
}
if (mChoice.choices == null || mChoice.choices.size() == 0) {
return;
}
List<ShortcutInfo> choiceShortcuts = new ArrayList<>();
int rank = 1;
for (Choice choice : mChoice.choices) {
ShortcutInfo choiceShortcut = new ShortcutInfo.Builder(this, IdUtil.getRandomUniqueShortcutId())
.setShortLabel(choice.action)
.setLongLabel(choice.action)
.setDisabledMessage(getString(R.string.shortcut_disabled_message))
.setIcon(Icon.createWithBitmap(choice.getActionEmoji(this)))
.setIntent(IntentUtil.choice(this, choice))
.setRank(rank)
.build();
choiceShortcuts.add(choiceShortcut);
rank++;
}
shortcutManager.setDynamicShortcuts(choiceShortcuts);
}
ChoiceActivity.java 文件源码
java
阅读 26
收藏 0
点赞 0
评论 0
项目:shortstories
作者:
评论列表
文章目录