List of usage examples for android.content.pm LauncherApps getShortcuts
@Nullable
public List<ShortcutInfo> getShortcuts(@NonNull ShortcutQuery query, @NonNull UserHandle user)
From source file:com.farmerbb.taskbar.activity.ContextMenuActivity.java
@TargetApi(Build.VERSION_CODES.N_MR1) private int getLauncherShortcuts() { LauncherApps launcherApps = (LauncherApps) getSystemService(LAUNCHER_APPS_SERVICE); if (launcherApps.hasShortcutHostPermission()) { UserManager userManager = (UserManager) getSystemService(USER_SERVICE); LauncherApps.ShortcutQuery query = new LauncherApps.ShortcutQuery(); query.setActivity(ComponentName.unflattenFromString(componentName)); query.setQueryFlags(/*from w w w .jav a2 s . c o m*/ LauncherApps.ShortcutQuery.FLAG_MATCH_DYNAMIC | LauncherApps.ShortcutQuery.FLAG_MATCH_MANIFEST | LauncherApps.ShortcutQuery.FLAG_MATCH_PINNED); shortcuts = launcherApps.getShortcuts(query, userManager.getUserForSerialNumber(userId)); if (shortcuts != null) return shortcuts.size(); } return 0; }