本文整理汇总了Java中android.content.pm.ShortcutManager.disableShortcuts方法的典型用法代码示例。如果您正苦于以下问题:Java ShortcutManager.disableShortcuts方法的具体用法?Java ShortcutManager.disableShortcuts怎么用?Java ShortcutManager.disableShortcuts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.pm.ShortcutManager
的用法示例。
在下文中一共展示了ShortcutManager.disableShortcuts方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removePinnedShortcut
import android.content.pm.ShortcutManager; //导入方法依赖的package包/类
@TargetApi(26)
public void removePinnedShortcut(Card card) {
ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class);
if (shortcutManager.isRequestPinShortcutSupported()) {
List<String> toRemove = new ArrayList<>();
toRemove.add(card.getName() + "_pin");
shortcutManager.disableShortcuts(toRemove, context.getString(R.string.error_no_longer_in_library));
}
}
示例2: disableExistingShortcuts
import android.content.pm.ShortcutManager; //导入方法依赖的package包/类
private void disableExistingShortcuts() {
ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
List<String> shortcutIds = new ArrayList<>();
for (ShortcutInfo shortcutInfo: shortcutManager.getDynamicShortcuts()) {
shortcutIds.add(shortcutInfo.getId());
}
shortcutManager.disableShortcuts(shortcutIds);
}
示例3: removeIncognitoLauncherShortcut
import android.content.pm.ShortcutManager; //导入方法依赖的package包/类
/**
* 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);
}
示例4: createOrRemoveRenameShortcutApi26
import android.content.pm.ShortcutManager; //导入方法依赖的package包/类
/**
* Create or remove rename shortcut from the home screen using ShortcutManager from API 25.
*
* @param create True if the shortcut should be created.
*/
@TargetApi(26)
private void createOrRemoveRenameShortcutApi26(boolean create) {
ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
if (shortcutManager.isRequestPinShortcutSupported()) {
if (create) {
String label = mApplication.getApplicationContext().getString(R.string.rename_shortcut_name);
ShortcutInfo shortcut = new ShortcutInfo.Builder(this, DSCApplication.ID_SHORTCUT_RENAME)
.setShortLabel(label)
.setLongLabel(label)
.setIcon(Icon.createWithResource(mApplication.getApplicationContext(),
R.drawable.ic_manual_rename))
.setIntent(getActivityIntent())
.build();
try {
shortcutManager.requestPinShortcut(shortcut, null);
mApplication.updateShortcutPref(TYPE.INSTALL);
updateShortcutFields();
} catch (IllegalArgumentException e) {
showAlertDialog(android.R.drawable.ic_dialog_info,
mApplication.getApplicationContext().getString(R.string.create_rename_shortcut_v26_error),
DO_NOT_SHOW_IGNORED);
}
} else {
shortcutManager.disableShortcuts(Arrays.asList(DSCApplication.ID_SHORTCUT_RENAME));
mApplication.updateShortcutPref(TYPE.UNINSTALL);
updateShortcutFields();
}
}
}
示例5: updateDynamicShortcuts
import android.content.pm.ShortcutManager; //导入方法依赖的package包/类
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();
}
}
}
}
示例6: disablePostShortcut
import android.content.pm.ShortcutManager; //导入方法依赖的package包/类
@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);
}
示例7: removeAllShortcuts
import android.content.pm.ShortcutManager; //导入方法依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.N_MR1)
public static void removeAllShortcuts(Context context) {
ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class);
shortcutManager.disableShortcuts(Arrays.asList(ApplicationConstants.SEARCH_SHORTCUT_ID));
shortcutManager.removeAllDynamicShortcuts();
}