Java 类android.content.pm.LauncherApps 实例源码

项目:LaunchEnr    文件:ShortcutConfigActivityInfo.java   
@Override
public boolean startConfigActivity(Activity activity, int requestCode) {
    if (getUser().equals(Process.myUserHandle())) {
        return super.startConfigActivity(activity, requestCode);
    }
    try {
        Method m = LauncherApps.class.getDeclaredMethod(
                "getShortcutConfigActivityIntent", LauncherActivityInfo.class);
        IntentSender is = (IntentSender) m.invoke(
                activity.getSystemService(LauncherApps.class), mInfo);
        activity.startIntentSenderForResult(is, requestCode, null, 0, 0, 0);
        return true;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}
项目:Taskbar    文件: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(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;
}
项目:LaunchEnr    文件:LauncherAppsCompatVO.java   
@Override
public List<ShortcutConfigActivityInfo> getCustomShortcutActivityList(
        @Nullable PackageUserKey packageUser) {
    List<ShortcutConfigActivityInfo> result = new ArrayList<>();
    UserHandle myUser = Process.myUserHandle();

    try {
        Method m = LauncherApps.class.getDeclaredMethod("getShortcutConfigActivityList",
                String.class, UserHandle.class);
        final List<UserHandle> users;
        final String packageName;
        if (packageUser == null) {
            users = UserManagerCompat.getInstance(mContext).getUserProfiles();
            packageName = null;
        } else {
            users = new ArrayList<>(1);
            users.add(packageUser.mUser);
            packageName = packageUser.mPackageName;
        }
        for (UserHandle user : users) {
            boolean ignoreTargetSdk = myUser.equals(user);
            List<LauncherActivityInfo> activities =
                    (List<LauncherActivityInfo>) m.invoke(mLauncherApps, packageName, user);
            for (LauncherActivityInfo activityInfo : activities) {
                if (ignoreTargetSdk || activityInfo.getApplicationInfo().targetSdkVersion >=
                        Build.VERSION_CODES.O) {
                    result.add(new ShortcutConfigActivityInfoVO(activityInfo));
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    return result;
}
项目:Paper-Launcher    文件:ShortcutsLoader.java   
@SuppressLint("WrongConstant")
public static List<ShortcutInfo> loadShortcuts(Context context, String packageName) {
    if (!SDKUtil.AT_LEAST_N_MR1) {
        return null;
    }

    LauncherApps launcherApps = (LauncherApps) context.getSystemService(Context.LAUNCHER_APPS_SERVICE);
    if (launcherApps == null) {
        return null;
    }

    if (!launcherApps.hasShortcutHostPermission()) {
        return null;
    }

    PackageManager packageManager = context.getPackageManager();
    Intent mainIntent = new Intent("android.intent.action.MAIN", null);
    mainIntent.addCategory("android.intent.category.LAUNCHER");

    if (packageManager != null && packageManager.queryIntentActivities(mainIntent, 0) != null) {
        try {
            return launcherApps.getShortcuts((new LauncherApps.ShortcutQuery())
                            .setPackage(packageName).setQueryFlags(QUERY_FLAGS),
                    UserHandle.getUserHandleForUid(context.getPackageManager().getPackageUid(packageName, PackageManager.GET_META_DATA)));
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();

            return null;
        }
    }

    return null;
}
项目:Paper-Launcher    文件:ShortcutUtil.java   
public static Drawable loadDrawable(Context context, ShortcutInfo shortcutInfo) {
    if (!SDKUtil.AT_LEAST_N_MR1) {
        return null;
    }

    return ((LauncherApps) context.getSystemService(Context.LAUNCHER_APPS_SERVICE))
            .getShortcutIconDrawable(shortcutInfo, context.getResources().getDisplayMetrics().densityDpi);
}
项目:Paper-Launcher    文件:ShortcutUtil.java   
public static void launchShortcut(View view, ShortcutInfo shortcutInfo) {
    if (!SDKUtil.AT_LEAST_N_MR1) {
        return;
    }

    ((LauncherApps) view.getContext().getSystemService(Context.LAUNCHER_APPS_SERVICE))
            .startShortcut(shortcutInfo, IntentUtil.getViewBounds(view), new Bundle());
}
项目:Taskbar    文件:U.java   
private static void launchAndroidForWork(Context context, ComponentName componentName, Bundle bundle, long userId) {
    UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
    LauncherApps launcherApps = (LauncherApps) context.getSystemService(Context.LAUNCHER_APPS_SERVICE);

    try {
        launcherApps.startMainActivity(componentName, userManager.getUserForSerialNumber(userId), null, bundle);
    } catch (ActivityNotFoundException | NullPointerException e) { /* Gracefully fail */ }
}
项目:Taskbar    文件:U.java   
@TargetApi(Build.VERSION_CODES.N_MR1)
private static void launchShortcut(Context context, ShortcutInfo shortcut, Bundle bundle) {
    LauncherApps launcherApps = (LauncherApps) context.getSystemService(Context.LAUNCHER_APPS_SERVICE);

    if(launcherApps.hasShortcutHostPermission()) {
        try {
            launcherApps.startShortcut(shortcut, null, bundle);
        } catch (ActivityNotFoundException | NullPointerException e) { /* Gracefully fail */ }
    }
}
项目:LaunchEnr    文件:LauncherAppsCompatVL.java   
LauncherAppsCompatVL(Context context) {
    mContext = context;
    mLauncherApps = (LauncherApps) context.getSystemService(Context.LAUNCHER_APPS_SERVICE);
}
项目:LaunchEnr    文件:DeepShortcutManager.java   
private DeepShortcutManager(Context context) {
    mLauncherApps = (LauncherApps) context.getSystemService(Context.LAUNCHER_APPS_SERVICE);
}
项目:LaunchEnr    文件:PinShortcutRequestActivityInfo.java   
@Override
public Drawable getFullResIcon(IconCache cache) {
    return mContext.getSystemService(LauncherApps.class)
            .getShortcutIconDrawable(mInfo, LauncherAppState.getIDP(mContext).fillResIconDpi);
}
项目:EasyAndroid    文件:Managers.java   
/**
 * 返回 {@link LauncherApps}
 */
public static LauncherApps getLauncherApps()
{
    return (LauncherApps) get(LAUNCHER_APPS_SERVICE);
}
项目:FlickLauncher    文件:LauncherAppsCompatVL.java   
LauncherAppsCompatVL(Context context) {
    super(context);
    mLauncherApps = (LauncherApps) context.getSystemService("launcherapps");
}
项目:FlickLauncher    文件:DeepShortcutManagerN.java   
DeepShortcutManagerN(Context context) {
    mLauncherApps = (LauncherApps) context.getSystemService(Context.LAUNCHER_APPS_SERVICE);
}
项目:FlickLauncher    文件:DeepShortcutManagerPreN.java   
public DeepShortcutManagerPreN(Context context) {
    mContext = context;
    mLauncherApps = (LauncherApps) context.getSystemService(Context.LAUNCHER_APPS_SERVICE);
    mEnableBackport = true;
}
项目:SimpleUILauncher    文件:LauncherAppsCompatVL.java   
LauncherAppsCompatVL(Context context) {
    super(context);
    mLauncherApps = (LauncherApps) context.getSystemService("launcherapps");
}
项目:SimpleUILauncher    文件:DeepShortcutManager.java   
public DeepShortcutManager(Context context, ShortcutCache shortcutCache) {
    mLauncherApps = (LauncherApps) context.getSystemService(Context.LAUNCHER_APPS_SERVICE);
}
项目:SimplOS    文件:LauncherAppsCompatVL.java   
LauncherAppsCompatVL(Context context) {
    super();
    mLauncherApps = (LauncherApps) context.getSystemService("launcherapps");
}
项目:Trebuchet    文件:LauncherAppsCompatVL.java   
LauncherAppsCompatVL(Context context) {
    super();
    mLauncherApps = (LauncherApps) context.getSystemService("launcherapps");
}
项目:MostTool    文件:AppListActivity.java   
public AppAdapter(Context context) {
    mInflater = LayoutInflater.from(context);
    LauncherApps launcherApps = (LauncherApps)getSystemService(Context.LAUNCHER_APPS_SERVICE);
    mData = launcherApps.getActivityList(null, android.os.Process.myUserHandle());
}
项目:Android-App-Template    文件:ServiceUtil.java   
@TargetApi(21)
public static LauncherApps getLauncherApps() {
    return (LauncherApps) getSystemService(Context.LAUNCHER_APPS_SERVICE);
}
项目:FLauncher    文件:LauncherAppsCompatVL.java   
LauncherAppsCompatVL(Context context) {
    super();
    mLauncherApps = (LauncherApps) context.getSystemService("launcherapps");
}
项目:sprockets-android    文件:Managers.java   
/**
 * @since 4.0.0
 */
public static LauncherApps launcherApps(Context context) {
    return (LauncherApps) context.getSystemService(LAUNCHER_APPS_SERVICE);
}
项目:MostTool    文件:AppListActivity.java   
public AppAdapter(Context context) {
    mInflater = LayoutInflater.from(context);
    LauncherApps launcherApps = (LauncherApps)getSystemService(Context.LAUNCHER_APPS_SERVICE);
    mData = launcherApps.getActivityList(null, android.os.Process.myUserHandle());
}
项目:LB-Launcher    文件:LauncherAppsCompatVL.java   
LauncherAppsCompatVL(Context context) {
    super();
    mLauncherApps = (LauncherApps) context.getSystemService("launcherapps");
}
项目:LeanLauncher    文件:LauncherAppsCompatVL.java   
LauncherAppsCompatVL(Context context) {
    super();
    mLauncherApps = (LauncherApps) context.getSystemService(Context.LAUNCHER_APPS_SERVICE);
}
项目:deagle    文件:LauncherAppsCompat.java   
public LauncherAppsCompat(final Context context) {
    mLauncherApps = (LauncherApps) context.getSystemService(Context.LAUNCHER_APPS_SERVICE);
}
项目:android_Skeleton    文件:SystemServices.java   
@TargetApi(AndroidHelper.API_21)
public static LauncherApps launcherApps() {
    return (LauncherApps) get(Context.LAUNCHER_APPS_SERVICE);
}
项目:android-wheels    文件:ContextUtils.java   
/**
 * Obtain a {@link LauncherApps} instance associated with specified {@link Context}
 *
 * @param context Context
 * @return {@link LauncherApps} associated with specified {@link Context}
 * @throws InvalidContextException if {@link LauncherApps} can't be obtained
 *                                 from specified {@link Context}
 */
@NonNull
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
public static LauncherApps getLauncherApps(@NonNull Context context) {
    return validate(context.getSystemService(Context.LAUNCHER_APPS_SERVICE));
}