ShortcutManager shortcutManager =getSystemService(ShortcutManager.class);ShortcutInfo shortcut =newShortcutInfo.Builder(this,"id1").setShortLabel("Web site")// Shortcut Icon tab.setLongLabel("Open the web site")// Displayed When Long Pressing On App Icon.setIcon(Icon.createWithResource(context,R.drawable.icon_website)).setIntent(newIntent(Intent.ACTION_VIEW,Uri.parse("https://www.mysite.example.com/"))).build();
shortcutManager.setDynamicShortcuts(Arrays.asList(shortcut));
We can remove all dynamic shortcuts easily by calling :-
Please note that setDynamicShortcuts(List)is used to redefine the entire list of dynamic shortcuts, addDynamicShortcuts(List) is used to add dynamic shortcuts to existing list of dynamic shortcuts