Java Code Examples for android.content.pm.ShortcutManager#disableShortcuts()

The following examples show how to use android.content.pm.ShortcutManager#disableShortcuts() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LauncherShortcutActivity.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Removes the dynamic "New incognito tab" launcher shortcut.
 * @param context The context used to retrieve the system {@link ShortcutManager}.
 */
@TargetApi(Build.VERSION_CODES.N_MR1)
private static void removeIncognitoLauncherShortcut(Context context) {
    List<String> shortcutList = new ArrayList<>();
    shortcutList.add(DYNAMIC_OPEN_NEW_INCOGNITO_TAB_ID);

    ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class);
    shortcutManager.disableShortcuts(shortcutList);
    shortcutManager.removeDynamicShortcuts(shortcutList);
}
 
Example 2
Source File: MainActivity.java    From android-wallet-app with GNU General Public License v3.0 4 votes vote down vote up
private void updateDynamicShortcuts() {
    ShortcutManager shortcutManager;

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N_MR1) {

        Intent intentGenerateQrCode = new Intent(this, MainActivity.class);
        intentGenerateQrCode.setFlags((Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK));
        intentGenerateQrCode.setAction(Constants.ACTION_GENERATE_QR_CODE);

        ShortcutInfo shortcutGenerateQrCode = new ShortcutInfo.Builder(this, SHORTCUT_ID_GENERATE_QR_CODE)
                .setShortLabel(getString(R.string.shortcut_generate_qr_code))
                .setLongLabel(getString(R.string.shortcut_generate_qr_code))
                .setIcon(Icon.createWithResource(this, R.drawable.ic_shortcut_qr))
                .setIntent(intentGenerateQrCode)
                .build();

        Intent intentTransferIotas = new Intent(this, MainActivity.class);
        intentTransferIotas.setFlags((Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK));
        intentTransferIotas.setAction(Constants.ACTION_SEND_TRANSFER);

        ShortcutInfo shortcutTransferIotas = new ShortcutInfo.Builder(this, SHORTCUT_ID_SEND_TRANSFER)
                .setShortLabel(getString(R.string.shortcut_send_transfer))
                .setLongLabel(getString(R.string.shortcut_send_transfer))
                .setIcon(Icon.createWithResource(this, R.drawable.ic_shortcut_transaction))
                .setIntent(intentTransferIotas)
                .build();

        shortcutManager = getSystemService(ShortcutManager.class);

        if (shortcutManager != null) {
            if (IOTA.seed != null) {
                shortcutManager.setDynamicShortcuts(Arrays.asList(shortcutGenerateQrCode, shortcutTransferIotas));
                shortcutManager.enableShortcuts(Arrays.asList(SHORTCUT_ID_GENERATE_QR_CODE, SHORTCUT_ID_SEND_TRANSFER));
            } else {
                // remove shortcuts if Iota.seed.isEmpty()
                shortcutManager.disableShortcuts(Arrays.asList(SHORTCUT_ID_GENERATE_QR_CODE, SHORTCUT_ID_SEND_TRANSFER));
                shortcutManager.removeAllDynamicShortcuts();
            }
        }
    }
}
 
Example 3
Source File: ShortcutHelper.java    From android-proguards with Apache License 2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.N_MR1)
public static void disablePostShortcut(@NonNull Context context) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) return;
    ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class);
    shortcutManager.disableShortcuts(DYNAMIC_SHORTCUT_IDS);
}