List of usage examples for android.content Intent EXTRA_USER
String EXTRA_USER
To view the source code for android.content Intent EXTRA_USER.
Click Source Link
From source file:me.piebridge.prevent.framework.SystemReceiver.java
private boolean handleCheckLicense(Context context, Intent intent) { String user = intent.getStringExtra(Intent.EXTRA_USER); Map<String, Set<String>> users = new LinkedHashMap<String, Set<String>>(); for (Account account : ActivityManagerServiceHook.getAccountWatcher().getEnabledAccounts()) { Set<String> accounts = users.get(account.type); if (accounts == null) { accounts = new LinkedHashSet<String>(); users.put(account.type, accounts); }//from w w w . j a v a 2 s . c o m accounts.add(account.name); if (PackageUtils.equals(account.name, user)) { setResultCode(0x1); return true; } } String number = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getLine1Number(); if (number != null) { number = number.replace("-", ""); number = number.replace(" ", ""); Set<String> numbers = users.get(""); if (numbers == null) { numbers = new LinkedHashSet<String>(); users.put("", numbers); } numbers.add(number); if (PackageUtils.equals(number, user)) { setResultCode(0x1); return true; } } setResultCode(0x0); setResultData(users.toString()); return false; }
From source file:com.farmerbb.taskbar.activity.ContextMenuActivity.java
@SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.N_MR1)//w w w . jav a 2s .co m @Override public boolean onPreferenceClick(Preference p) { UserManager userManager = (UserManager) getSystemService(USER_SERVICE); LauncherApps launcherApps = (LauncherApps) getSystemService(LAUNCHER_APPS_SERVICE); boolean appIsValid = isStartButton || isOverflowMenu || !launcherApps.getActivityList(getIntent().getStringExtra("package_name"), userManager.getUserForSerialNumber(userId)).isEmpty(); if (appIsValid) switch (p.getKey()) { case "app_info": startFreeformActivity(); launcherApps.startAppDetailsActivity(ComponentName.unflattenFromString(componentName), userManager.getUserForSerialNumber(userId), null, null); showStartMenu = false; shouldHideTaskbar = true; contextMenuFix = false; break; case "uninstall": if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && isInMultiWindowMode()) { Intent intent2 = new Intent(ContextMenuActivity.this, DummyActivity.class); intent2.putExtra("uninstall", packageName); intent2.putExtra("user_id", userId); startFreeformActivity(); startActivity(intent2); } else { startFreeformActivity(); Intent intent2 = new Intent(Intent.ACTION_DELETE, Uri.parse("package:" + packageName)); intent2.putExtra(Intent.EXTRA_USER, userManager.getUserForSerialNumber(userId)); try { startActivity(intent2); } catch (ActivityNotFoundException e) { /* Gracefully fail */ } } showStartMenu = false; shouldHideTaskbar = true; contextMenuFix = false; break; case "open_taskbar_settings": startFreeformActivity(); Intent intent2 = new Intent(this, MainActivity.class); intent2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent2); showStartMenu = false; shouldHideTaskbar = true; contextMenuFix = false; break; case "quit_taskbar": Intent quitIntent = new Intent("com.farmerbb.taskbar.QUIT"); quitIntent.setPackage(BuildConfig.APPLICATION_ID); sendBroadcast(quitIntent); showStartMenu = false; shouldHideTaskbar = true; contextMenuFix = false; break; case "pin_app": PinnedBlockedApps pba = PinnedBlockedApps.getInstance(this); if (pba.isPinned(componentName)) pba.removePinnedApp(this, componentName); else { Intent intent = new Intent(); intent.setComponent(ComponentName.unflattenFromString(componentName)); LauncherActivityInfo appInfo = launcherApps.resolveActivity(intent, userManager.getUserForSerialNumber(userId)); if (appInfo != null) { AppEntry newEntry = new AppEntry(packageName, componentName, appName, IconCache.getInstance(this).getIcon(this, getPackageManager(), appInfo), true); newEntry.setUserId(userId); pba.addPinnedApp(this, newEntry); } } break; case "block_app": PinnedBlockedApps pba2 = PinnedBlockedApps.getInstance(this); if (pba2.isBlocked(componentName)) pba2.removeBlockedApp(this, componentName); else { pba2.addBlockedApp(this, new AppEntry(packageName, componentName, appName, null, false)); } break; case "show_window_sizes": getPreferenceScreen().removeAll(); addPreferencesFromResource(R.xml.pref_context_menu_window_size_list); findPreference("window_size_standard").setOnPreferenceClickListener(this); findPreference("window_size_large").setOnPreferenceClickListener(this); findPreference("window_size_fullscreen").setOnPreferenceClickListener(this); findPreference("window_size_half_left").setOnPreferenceClickListener(this); findPreference("window_size_half_right").setOnPreferenceClickListener(this); findPreference("window_size_phone_size").setOnPreferenceClickListener(this); SharedPreferences pref = U.getSharedPreferences(this); if (pref.getBoolean("save_window_sizes", true)) { String windowSizePref = SavedWindowSizes.getInstance(this).getWindowSize(this, packageName); CharSequence title = findPreference("window_size_" + windowSizePref).getTitle(); findPreference("window_size_" + windowSizePref).setTitle('\u2713' + " " + title); } if (U.isOPreview()) { U.showToast(this, R.string.window_sizes_not_available); } secondaryMenu = true; break; case "window_size_standard": case "window_size_large": case "window_size_fullscreen": case "window_size_half_left": case "window_size_half_right": case "window_size_phone_size": String windowSize = p.getKey().replace("window_size_", ""); SharedPreferences pref2 = U.getSharedPreferences(this); if (pref2.getBoolean("save_window_sizes", true)) { SavedWindowSizes.getInstance(this).setWindowSize(this, packageName, windowSize); } startFreeformActivity(); U.launchApp(getApplicationContext(), packageName, componentName, userId, windowSize, false, true); showStartMenu = false; shouldHideTaskbar = true; contextMenuFix = false; break; case "app_shortcuts": getPreferenceScreen().removeAll(); generateShortcuts(); secondaryMenu = true; break; case "shortcut_1": case "shortcut_2": case "shortcut_3": case "shortcut_4": case "shortcut_5": U.startShortcut(getApplicationContext(), packageName, componentName, shortcuts.get(Integer.parseInt(p.getKey().replace("shortcut_", "")) - 1)); showStartMenu = false; shouldHideTaskbar = true; contextMenuFix = false; break; case "start_menu_apps": startFreeformActivity(); Intent intent = null; SharedPreferences pref3 = U.getSharedPreferences(this); switch (pref3.getString("theme", "light")) { case "light": intent = new Intent(this, SelectAppActivity.class); break; case "dark": intent = new Intent(this, SelectAppActivityDark.class); break; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && pref3.getBoolean("freeform_hack", false) && intent != null && isInMultiWindowMode()) { intent.putExtra("no_shadow", true); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT); U.launchAppMaximized(getApplicationContext(), intent); } else startActivity(intent); showStartMenu = false; shouldHideTaskbar = true; contextMenuFix = false; break; case "volume": AudioManager audio = (AudioManager) getSystemService(AUDIO_SERVICE); audio.adjustSuggestedStreamVolume(AudioManager.ADJUST_SAME, AudioManager.USE_DEFAULT_STREAM_TYPE, AudioManager.FLAG_SHOW_UI); showStartMenu = false; shouldHideTaskbar = true; contextMenuFix = false; break; case "file_manager": Intent fileManagerIntent; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { startFreeformActivity(); fileManagerIntent = new Intent("android.provider.action.BROWSE"); } else { fileManagerIntent = new Intent("android.provider.action.BROWSE_DOCUMENT_ROOT"); fileManagerIntent.setComponent( ComponentName.unflattenFromString("com.android.documentsui/.DocumentsActivity")); } fileManagerIntent.addCategory(Intent.CATEGORY_DEFAULT); fileManagerIntent .setData(Uri.parse("content://com.android.externalstorage.documents/root/primary")); try { startActivity(fileManagerIntent); } catch (ActivityNotFoundException e) { U.showToast(this, R.string.lock_device_not_supported); } showStartMenu = false; shouldHideTaskbar = true; contextMenuFix = false; break; case "system_settings": startFreeformActivity(); Intent settingsIntent = new Intent(Settings.ACTION_SETTINGS); try { startActivity(settingsIntent); } catch (ActivityNotFoundException e) { U.showToast(this, R.string.lock_device_not_supported); } showStartMenu = false; shouldHideTaskbar = true; contextMenuFix = false; break; case "lock_device": U.lockDevice(this); showStartMenu = false; shouldHideTaskbar = true; contextMenuFix = false; break; case "power_menu": U.sendAccessibilityAction(this, AccessibilityService.GLOBAL_ACTION_POWER_DIALOG); showStartMenu = false; shouldHideTaskbar = true; contextMenuFix = false; break; case "change_wallpaper": Intent intent3 = Intent.createChooser(new Intent(Intent.ACTION_SET_WALLPAPER), getString(R.string.set_wallpaper)); intent3.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); U.launchAppMaximized(getApplicationContext(), intent3); showStartMenu = false; shouldHideTaskbar = true; contextMenuFix = false; break; } if (!secondaryMenu) finish(); return true; }
From source file:com.android.leanlauncher.LauncherTransitionable.java
boolean startApplicationUninstallActivity(ComponentName componentName, int flags, UserHandleCompat user) { if ((flags & AppInfo.DOWNLOADED_FLAG) == 0) { // System applications cannot be installed. For now, show a toast explaining that. // We may give them the option of disabling apps this way. int messageId = R.string.uninstall_system_app_text; Toast.makeText(this, messageId, Toast.LENGTH_SHORT).show(); return false; } else {/* w w w . j ava 2s . co m*/ String packageName = componentName.getPackageName(); String className = componentName.getClassName(); Intent intent = new Intent(Intent.ACTION_DELETE, Uri.fromParts("package", packageName, className)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); if (user != null) { user.addToIntent(intent, Intent.EXTRA_USER); } startActivity(intent); return true; } }
From source file:com.klinker.android.launcher.launcher3.Launcher.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public ItemInfo createAppDragInfo(Intent appLaunchIntent) { // Called from search suggestion UserHandleCompat user = null;/*from www.j a va 2s .c o m*/ if (Utilities.isLmpOrAbove()) { UserHandle userHandle = appLaunchIntent.getParcelableExtra(Intent.EXTRA_USER); if (userHandle != null) { user = UserHandleCompat.fromUser(userHandle); } } return createAppDragInfo(appLaunchIntent, user); }
From source file:com.android.launcher3.Launcher.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public ItemInfo createAppDragInfo(Intent appLaunchIntent) { // Called from search suggestion UserHandleCompat user = null;// w w w . j av a2s. c o m if (Utilities.ATLEAST_LOLLIPOP) { UserHandle userHandle = appLaunchIntent.getParcelableExtra(Intent.EXTRA_USER); if (userHandle != null) { user = UserHandleCompat.fromUser(userHandle); } } return createAppDragInfo(appLaunchIntent, user); }