本文整理汇总了Java中android.content.pm.ShortcutManager.removeAllDynamicShortcuts方法的典型用法代码示例。如果您正苦于以下问题:Java ShortcutManager.removeAllDynamicShortcuts方法的具体用法?Java ShortcutManager.removeAllDynamicShortcuts怎么用?Java ShortcutManager.removeAllDynamicShortcuts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.pm.ShortcutManager
的用法示例。
在下文中一共展示了ShortcutManager.removeAllDynamicShortcuts方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addChoiceShortcuts
import android.content.pm.ShortcutManager; //导入方法依赖的package包/类
private void addChoiceShortcuts() {
ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
if (mChoice.isFinish()) {
shortcutManager.removeAllDynamicShortcuts();
return;
}
if (mChoice.choices == null || mChoice.choices.size() == 0) {
return;
}
List<ShortcutInfo> choiceShortcuts = new ArrayList<>();
int rank = 1;
for (Choice choice : mChoice.choices) {
ShortcutInfo choiceShortcut = new ShortcutInfo.Builder(this, IdUtil.getRandomUniqueShortcutId())
.setShortLabel(choice.action)
.setLongLabel(choice.action)
.setDisabledMessage(getString(R.string.shortcut_disabled_message))
.setIcon(Icon.createWithBitmap(choice.getActionEmoji(this)))
.setIntent(IntentUtil.choice(this, choice))
.setRank(rank)
.build();
choiceShortcuts.add(choiceShortcut);
rank++;
}
shortcutManager.setDynamicShortcuts(choiceShortcuts);
}
示例2: setShortcut
import android.content.pm.ShortcutManager; //导入方法依赖的package包/类
@Override
public void setShortcut(String did, String manufacturer, String deviceName) {
//Home screen shortcut for favourite device
if (Build.VERSION.SDK_INT < 25)
return;
ShortcutManager sM = getSystemService(ShortcutManager.class);
sM.removeAllDynamicShortcuts();
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
intent.setAction(Intent.ACTION_VIEW);
intent.putExtra(Constants.EXTRA_DEVICE_ID, did);
ShortcutInfo shortcut = new ShortcutInfo.Builder(this, "shortcut1")
.setIntent(intent)
.setLongLabel(manufacturer + " " + deviceName)
.setShortLabel(deviceName)
.setIcon(Icon.createWithResource(this, R.drawable.ic_device_placeholder))
.build();
sM.setDynamicShortcuts(Collections.singletonList(shortcut));
}
示例3: updateShortcuts
import android.content.pm.ShortcutManager; //导入方法依赖的package包/类
public static void updateShortcuts(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class);
shortcutManager.removeAllDynamicShortcuts();
List<PreferredJourney> l;
if ((l = PreferredStationsPreferences.getAllPreferredJourneys(context)).size() > 0) {
shortcutManager.addDynamicShortcuts(setShortcuts(context, l.get(0)));
}
}
}
示例4: onCreate
import android.content.pm.ShortcutManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
shortcutManager.removeAllDynamicShortcuts();
int newWallId = ShortcutsUtils.getNextRailNumber(shortcutManager);
ShortcutInfo ballShortcut = ShortcutsUtils.createTrainShortcut(this);
ShortcutInfo wallShortcut = ShortcutsUtils.createRailShortcut(this, newWallId);
shortcutManager.setDynamicShortcuts(Arrays.asList(ballShortcut, wallShortcut));
setContentView(R.layout.activity_main);
rootView = findViewById(R.id.activity_main_root);
viewPager = (ViewPager) findViewById(R.id.activity_main_view_pager);
pagerAdapter = new TutorialViewPagerAdapter(getFragmentManager());
viewPager.setAdapter(pagerAdapter);
rootView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finishActivity();
}
});
}
示例5: removeAllShortcuts
import android.content.pm.ShortcutManager; //导入方法依赖的package包/类
private void removeAllShortcuts() {
ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
shortcutManager.removeAllDynamicShortcuts();
}
示例6: 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();
}
}
}
}
示例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();
}
示例8: setShortcuts
import android.content.pm.ShortcutManager; //导入方法依赖的package包/类
private void setShortcuts() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) return;
PriorityQueue<Class<? extends Fragment>> queue = new PriorityQueue<>(
new Comparator<Class<? extends Fragment>>() {
@Override
public int compare(Class<? extends Fragment> o1, Class<? extends Fragment> o2) {
int opened1 = Prefs.getInt(o1.getSimpleName() + "_opened",
0, NavigationActivity.this);
int opened2 = Prefs.getInt(o2.getSimpleName() + "_opened",
0, NavigationActivity.this);
return opened2 - opened1;
}
});
for (Map.Entry<Integer, Class<? extends Fragment>> entry : mActualFragments.entrySet()) {
Class<? extends Fragment> fragmentClass = entry.getValue();
if (fragmentClass == null || fragmentClass == SettingsFragment.class) continue;
queue.offer(fragmentClass);
}
List<ShortcutInfo> shortcutInfos = new ArrayList<>();
ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
shortcutManager.removeAllDynamicShortcuts();
for (int i = 0; i < 4; i++) {
NavigationFragment fragment = findNavigationFragmentByClass(queue.poll());
Intent intent = new Intent(this, MainActivity.class);
intent.setAction(Intent.ACTION_VIEW);
intent.putExtra("section", fragment.mFragmentClass.getCanonicalName());
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
ShortcutInfo shortcut = new ShortcutInfo.Builder(this,
fragment.mFragmentClass.getSimpleName())
.setShortLabel(getString(fragment.mId))
.setLongLabel(Utils.strFormat(getString(R.string.open), getString(fragment.mId)))
.setIcon(Icon.createWithResource(this, fragment.mDrawable == 0 ?
R.drawable.ic_blank : fragment.mDrawable))
.setIntent(intent)
.build();
shortcutInfos.add(shortcut);
}
shortcutManager.setDynamicShortcuts(shortcutInfos);
}