当前位置: 首页>>代码示例>>Java>>正文


Java UserHandle.equals方法代码示例

本文整理汇总了Java中android.os.UserHandle.equals方法的典型用法代码示例。如果您正苦于以下问题:Java UserHandle.equals方法的具体用法?Java UserHandle.equals怎么用?Java UserHandle.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.os.UserHandle的用法示例。


在下文中一共展示了UserHandle.equals方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startActivitySafely

import android.os.UserHandle; //导入方法依赖的package包/类
public boolean startActivitySafely(View v, Intent intent, ItemInfo item) {
    if (mIsSafeModeEnabled && !Utilities.isSystemApp(this, intent)) {
        Toast.makeText(this, R.string.safemode_shortcut_error, Toast.LENGTH_SHORT).show();
        return false;
    }
    // Only launch using the new animation if the shortcut has not opted out (this is a
    // private contract between launcher and may be ignored in the future).
    boolean useLaunchAnimation = (v != null) &&
            !intent.hasExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION);
    Bundle optsBundle = useLaunchAnimation ? getActivityLaunchOptions(v) : null;

    UserHandle user = item == null ? null : item.user;

    // Prepare intent
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (v != null) {
        intent.setSourceBounds(getViewBounds(v));
    }
    try {
        if (AndroidVersion.isAtLeastMarshmallow
                && (item instanceof ShortcutInfo)
                && (item.itemType == Favorites.ITEM_TYPE_SHORTCUT
                 || item.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT)
                && !((ShortcutInfo) item).isPromise()) {
            // Shortcuts need some special checks due to legacy reasons.
            startShortcutIntentSafely(intent, optsBundle, item);
        } else if (user == null || user.equals(Process.myUserHandle())) {
            // Could be launching some bookkeeping activity
            startActivity(intent, optsBundle);
        } else {
            LauncherAppsCompat.getInstance(this).startActivityForProfile(
                    intent.getComponent(), user, intent.getSourceBounds(), optsBundle);
        }
        return true;
    } catch (ActivityNotFoundException|SecurityException e) {
        Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
        e.printStackTrace();
    }
    return false;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:41,代码来源:Launcher.java

示例2: markExistingUsersForNoFolderCreation

import android.os.UserHandle; //导入方法依赖的package包/类
/**
 * For each user, if a work folder has not been created, mark it such that the folder will
 * never get created.
 */
public static void markExistingUsersForNoFolderCreation(Context context) {
    UserManagerCompat userManager = UserManagerCompat.getInstance(context);
    UserHandle myUser = Process.myUserHandle();

    SharedPreferences prefs = null;
    for (UserHandle user : userManager.getUserProfiles()) {
        if (myUser.equals(user)) {
            continue;
        }

        if (prefs == null) {
            prefs = context.getSharedPreferences(
                    LauncherFiles.MANAGED_USER_PREFERENCES_KEY,
                    Context.MODE_PRIVATE);
        }
        String folderIdKey = USER_FOLDER_ID_PREFIX + userManager.getSerialNumberForUser(user);
        if (!prefs.contains(folderIdKey)) {
            prefs.edit().putLong(folderIdKey, ItemInfo.NO_ID).apply();
        }
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:26,代码来源:ManagedProfileHeuristic.java

示例3: notifyChange

import android.os.UserHandle; //导入方法依赖的package包/类
@SuppressLint("NewApi")
private void notifyChange(final Uri uri) {
    // If the calling user is different than current one, we need to post a
    // task to notify change, otherwise, a system level hidden permission
    // INTERACT_ACROSS_USERS_FULL is needed.
    // The related APIs were added in API 17, it should be safe to fallback to
    // normal way for notifying change, because caller can't be other users in
    // devices whose API level is less than API 17.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        UserHandle callingUserHandle = Binder.getCallingUserHandle();
        if (callingUserHandle != null
                && !callingUserHandle.equals(android.os.Process.myUserHandle())) {
            ThreadUtils.postOnUiThread(new Runnable() {
                @Override
                public void run() {
                    getContext().getContentResolver().notifyChange(uri, null);
                }
            });
            return;
        }
    }
    getContext().getContentResolver().notifyChange(uri, null);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:24,代码来源:ChromeBrowserProvider.java

示例4: getCustomShortcutActivityList

import android.os.UserHandle; //导入方法依赖的package包/类
@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;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:37,代码来源:LauncherAppsCompatVO.java

示例5: findApplicationInfoLocked

import android.os.UserHandle; //导入方法依赖的package包/类
/**
 * Find an ApplicationInfo object for the given packageName and className.
 */
private AppInfo findApplicationInfoLocked(String packageName, UserHandle user,
        String className) {
    for (AppInfo info: data) {
        if (user.equals(info.user) && packageName.equals(info.componentName.getPackageName())
                && className.equals(info.componentName.getClassName())) {
            return info;
        }
    }
    return null;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:14,代码来源:AllAppsList.java

示例6: removeFromInstallQueue

import android.os.UserHandle; //导入方法依赖的package包/类
public static void removeFromInstallQueue(Context context, HashSet<String> packageNames,
        UserHandle user) {
    if (packageNames.isEmpty()) {
        return;
    }
    SharedPreferences sp = Utilities.getPrefs(context);
    synchronized(sLock) {
        Set<String> strings = sp.getStringSet(APPS_PENDING_INSTALL, null);

        if (Utilities.isEmpty(strings)) {
            return;
        }
        Set<String> newStrings = new HashSet<>(strings);
        Iterator<String> newStringsIter = newStrings.iterator();
        while (newStringsIter.hasNext()) {
            String encoded = newStringsIter.next();
            try {
                Decoder decoder = new Decoder(encoded, context);
                if (packageNames.contains(getIntentPackage(decoder.launcherIntent)) &&
                        user.equals(decoder.user)) {
                    newStringsIter.remove();
                }
            } catch (JSONException | URISyntaxException e) {
                e.printStackTrace();
                newStringsIter.remove();
            }
        }
        sp.edit().putStringSet(APPS_PENDING_INSTALL, newStrings).apply();
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:31,代码来源:InstallShortcutReceiver.java


注:本文中的android.os.UserHandle.equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。