LauncherShortcutActivity.java 文件源码

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

项目:365browser 作者:
/**
 * Adds a "New incognito tab" dynamic launcher shortcut.
 * @param context The context used to retrieve the system {@link ShortcutManager}.
 * @return True if addint the shortcut has succeeded. False if the call fails due to rate
 *         limiting. See {@link ShortcutManager#addDynamicShortcuts}.
 */
@TargetApi(Build.VERSION_CODES.N_MR1)
private static boolean addIncognitoLauncherShortcut(Context context) {
    Intent intent = new Intent(LauncherShortcutActivity.ACTION_OPEN_NEW_INCOGNITO_TAB);
    intent.setPackage(context.getPackageName());
    intent.setClass(context, LauncherShortcutActivity.class);

    ShortcutInfo shortcut =
            new ShortcutInfo.Builder(context, DYNAMIC_OPEN_NEW_INCOGNITO_TAB_ID)
                    .setShortLabel(context.getResources().getString(
                            R.string.accessibility_tabstrip_incognito_identifier))
                    .setLongLabel(
                            context.getResources().getString(R.string.menu_new_incognito_tab))
                    .setIcon(Icon.createWithResource(context, R.drawable.shortcut_incognito))
                    .setIntent(intent)
                    .build();

    ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class);
    return shortcutManager.addDynamicShortcuts(Arrays.asList(shortcut));
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号