public ShortcutHelper createShortcutList(@NonNull List<Shortcut> shortcuts) {
if (Build.VERSION.SDK_INT < 25) {
return this;
}
mShortcutManager = mActivity.getSystemService(ShortcutManager.class);
for (int i=0; i<shortcuts.size(); i++) {
if (i < mShortcutManager.getMaxShortcutCountPerActivity()) {
String shortcutId = shortcuts.get(i).getShortLabel().replaceAll("\\s+","").toLowerCase() + "_shortcut";
ShortcutInfo shortcut = new ShortcutInfo.Builder(mActivity, shortcutId)
.setShortLabel(shortcuts.get(i).getShortLabel())
.setLongLabel(shortcuts.get(i).getLongLabel())
.setIcon(Icon.createWithResource(mActivity, shortcuts.get(i).getIconResource()))
.setIntent(shortcuts.get(i).getIntent())
.build();
mShortcutInfos.add(shortcut);
}
}
return this;
}
ShortcutHelper.java 文件源码
java
阅读 38
收藏 0
点赞 0
评论 0
项目:shortcut-helper
作者:
评论列表
文章目录