/**
* Update the dynamic shortcuts that are associated with this app. The given list of cards must
* be sorted by popularity. The amount parameter indicates how much shortcuts should be made.
*
* @param cards A list of cards that's sorted by popularity.
* @param amount Amount indicates the number n of cards for which a shortcut should be made from
* the list.
*/
public void updateDynamicShortcuts(List<Card> cards, int amount) {
if (cards.size() < amount) {
amount = cards.size();
}
this.cards = cards;
List<ShortcutInfo> shortcuts = new ArrayList<>();
ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class);
for (int i = 0; i < amount; i++) {
ShortcutInfo shortcut = new ShortcutInfo.Builder(context, cards.get(i).getName() + "-shortcut")
.setShortLabel(cards.get(i).getName())
.setIcon(Icon.createWithResource(context, R.drawable.shortcut_store))
.setIntent(createCardShortcutIntent(cards.get(i)))
.build();
shortcuts.add(shortcut);
}
shortcutManager.setDynamicShortcuts(shortcuts);
}
LauncherInfoManager.java 文件源码
java
阅读 23
收藏 0
点赞 0
评论 0
项目:Loyalty
作者:
评论列表
文章目录