ShortcutUtil.java 文件源码

java
阅读 28 收藏 0 点赞 0 评论 0

项目:SpotiQ 作者:
@RequiresApi(api = Build.VERSION_CODES.N_MR1)
public static void addSearchShortcut(Context context, String searchWithPartyTitle) {
    ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class);

    Intent openSearch = new Intent(context.getApplicationContext(), SearchActivity.class);
    openSearch.putExtra(ApplicationConstants.PARTY_NAME_EXTRA, searchWithPartyTitle);
    openSearch.setAction(Intent.ACTION_VIEW);

    ShortcutInfo shortcut = new ShortcutInfo.Builder(context, ApplicationConstants.SEARCH_SHORTCUT_ID)
        .setShortLabel("Search songs")
        .setLongLabel("Search for songs to add to the queue")
        .setIcon(Icon.createWithResource(context, R.drawable.ic_shortcut_search))
        .setIntent(openSearch)
        .build();

    shortcutManager.setDynamicShortcuts(Arrays.asList(shortcut));
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号