List of usage examples for android.content.pm PackageManager MATCH_DEFAULT_ONLY
int MATCH_DEFAULT_ONLY
To view the source code for android.content.pm PackageManager MATCH_DEFAULT_ONLY.
Click Source Link
From source file:com.limemobile.app.plugin.PluginHostDelegateFragmentActivity.java
@Override public void startActivityForResult(Intent intent, int requestCode) { List<ResolveInfo> resolveInfos = getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (resolveInfos == null || resolveInfos.isEmpty()) { intent.setPackage(mDelegatedActivity.getPackageName()); } else {// ww w. j a va2s. c o m super.startActivityForResult(intent, requestCode); return; } PluginClientManager.sharedInstance(this).startActivityForResult(this, intent, requestCode); }
From source file:com.google.android.apps.mytracks.fragments.ChooseActivityDialogFragment.java
/** * Gets the display info./*ww w . j a va 2 s .c om*/ */ private List<DisplayInfo> getDisplayInfos() { List<DisplayInfo> displayInfos = new ArrayList<DisplayInfo>(); Intent intent = ShareCompat.IntentBuilder.from(getActivity()).setType(IntentUtils.TEXT_PLAIN_TYPE) .getIntent(); List<ResolveInfo> resolveInfos = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (resolveInfos != null && resolveInfos.size() > 0) { int size = resolveInfos.size(); ResolveInfo firstResolveInfo = resolveInfos.get(0); for (int i = 1; i < size; i++) { ResolveInfo resolveInfo = resolveInfos.get(i); if (firstResolveInfo.priority != resolveInfo.priority || firstResolveInfo.isDefault != resolveInfo.isDefault) { while (i < size) { resolveInfos.remove(i); size--; } } } if (size > 1) { ResolveInfo.DisplayNameComparator displayNameComparator = new ResolveInfo.DisplayNameComparator( packageManager); Collections.sort(resolveInfos, displayNameComparator); } firstResolveInfo = resolveInfos.get(0); int start = 0; CharSequence firstLabel = firstResolveInfo.loadLabel(packageManager); for (int i = 1; i < size; i++) { if (firstLabel == null) { firstLabel = firstResolveInfo.activityInfo.packageName; } ResolveInfo resolveInfo = resolveInfos.get(i); CharSequence label = resolveInfo.loadLabel(packageManager); if (label == null) { label = resolveInfo.activityInfo.packageName; } if (label.equals(firstLabel)) { continue; } processGroup(resolveInfos, displayInfos, start, i - 1); firstResolveInfo = resolveInfo; firstLabel = label; start = i; } // Process last group processGroup(resolveInfos, displayInfos, start, size - 1); } return displayInfos; }
From source file:org.wahtod.wififixer.utility.LogUtil.java
public static void sendIssueReport(Activity activity, String report, File file) { Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.setType(activity.getString(R.string.log_mimetype)); sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { activity.getString(R.string.email) }); sendIntent.putExtra(Intent.EXTRA_SUBJECT, activity.getString(R.string.subject)); Uri uri = FileProvider.getUriForFile(activity, "org.wahtod.wififixer.files", file); sendIntent.putExtra(Intent.EXTRA_STREAM, uri); List<ResolveInfo> resInfoList = activity.getPackageManager().queryIntentActivities(sendIntent, PackageManager.MATCH_DEFAULT_ONLY); for (ResolveInfo resolveInfo : resInfoList) { String packageName = resolveInfo.activityInfo.packageName; activity.grantUriPermission(packageName, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION); }/*from w ww .j a v a 2s .c om*/ sendIntent.putExtra(Intent.EXTRA_TEXT, LogUtil.getBuildInfo() + "\n\n" + report); activity.startActivityForResult(Intent.createChooser(sendIntent, activity.getString(R.string.emailintent)), 1); }
From source file:com.limemobile.app.plugin.PluginHostDelegateFragmentActivity.java
@Override public void startActivityForResult(Intent intent, int requestCode, Bundle options) { List<ResolveInfo> resolveInfos = getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (resolveInfos == null || resolveInfos.isEmpty()) { intent.setPackage(mDelegatedActivity.getPackageName()); } else {//from w w w. j a v a 2s. c o m super.startActivityForResult(intent, requestCode, options); return; } PluginClientManager.sharedInstance(this).startActivityForResult(this, intent, requestCode, options); }
From source file:com.farmerbb.taskbar.fragment.FreeformModeFragment.java
@TargetApi(Build.VERSION_CODES.N) @Override// www . j av a 2 s.co m public boolean onPreferenceClick(final Preference p) { final SharedPreferences pref = U.getSharedPreferences(getActivity()); switch (p.getKey()) { case "freeform_hack": if (((CheckBoxPreference) p).isChecked()) { if (!U.hasFreeformSupport(getActivity())) { ((CheckBoxPreference) p).setChecked(false); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.freeform_dialog_title).setMessage(R.string.freeform_dialog_message) .setPositiveButton(R.string.action_developer_options, (dialogInterface, i) -> { showReminderToast = true; Intent intent = new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS); try { startActivity(intent); U.showToastLong(getActivity(), R.string.enable_force_activities_resizable); } catch (ActivityNotFoundException e) { intent = new Intent(Settings.ACTION_DEVICE_INFO_SETTINGS); try { startActivity(intent); U.showToastLong(getActivity(), R.string.enable_developer_options); } catch (ActivityNotFoundException e2) { /* Gracefully fail */ } } }); AlertDialog dialog = builder.create(); dialog.show(); dialog.setCancelable(false); } if (pref.getBoolean("taskbar_active", false) && getActivity().isInMultiWindowMode() && !FreeformHackHelper.getInstance().isFreeformHackActive()) { U.startFreeformHack(getActivity(), false, false); } } else { LocalBroadcastManager.getInstance(getActivity()) .sendBroadcast(new Intent("com.farmerbb.taskbar.FINISH_FREEFORM_ACTIVITY")); LocalBroadcastManager.getInstance(getActivity()) .sendBroadcast(new Intent("com.farmerbb.taskbar.FORCE_TASKBAR_RESTART")); } break; case "freeform_mode_help": AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(View.inflate(getActivity(), R.layout.freeform_help_dialog, null)) .setTitle(R.string.freeform_help_dialog_title).setPositiveButton(R.string.action_close, null); AlertDialog dialog = builder.create(); dialog.show(); break; case "add_shortcut": Intent intent = U.getShortcutIntent(getActivity()); intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); intent.putExtra("duplicate", false); Intent homeIntent = new Intent(Intent.ACTION_MAIN); homeIntent.addCategory(Intent.CATEGORY_HOME); ResolveInfo defaultLauncher = getActivity().getPackageManager().resolveActivity(homeIntent, PackageManager.MATCH_DEFAULT_ONLY); intent.setPackage(defaultLauncher.activityInfo.packageName); getActivity().sendBroadcast(intent); U.showToast(getActivity(), R.string.shortcut_created); break; case "window_size": if (U.isOPreview()) { U.showToast(getActivity(), R.string.window_sizes_not_available); } break; } return true; }
From source file:org.cowboycoders.cyclisimo.fragments.ChooseActivityDialogFragment.java
/** * Gets the display info.//from w w w . j a va 2 s. c o m */ private List<DisplayInfo> getDisplayInfos() { List<DisplayInfo> displayInfos = new ArrayList<DisplayInfo>(); Intent intent = ShareCompat.IntentBuilder.from(activity).setType(IntentUtils.TEXT_PLAIN_TYPE).getIntent(); List<ResolveInfo> resolveInfos = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (resolveInfos != null && resolveInfos.size() > 0) { int size = resolveInfos.size(); ResolveInfo firstResolveInfo = resolveInfos.get(0); for (int i = 1; i < size; i++) { ResolveInfo resolveInfo = resolveInfos.get(i); if (firstResolveInfo.priority != resolveInfo.priority || firstResolveInfo.isDefault != resolveInfo.isDefault) { while (i < size) { resolveInfos.remove(i); size--; } } } if (size > 1) { ResolveInfo.DisplayNameComparator displayNameComparator = new ResolveInfo.DisplayNameComparator( packageManager); Collections.sort(resolveInfos, displayNameComparator); } firstResolveInfo = resolveInfos.get(0); int start = 0; CharSequence firstLabel = firstResolveInfo.loadLabel(packageManager); for (int i = 1; i < size; i++) { if (firstLabel == null) { firstLabel = firstResolveInfo.activityInfo.packageName; } ResolveInfo resolveInfo = resolveInfos.get(i); CharSequence label = resolveInfo.loadLabel(packageManager); if (label == null) { label = resolveInfo.activityInfo.packageName; } if (label.equals(firstLabel)) { continue; } processGroup(resolveInfos, displayInfos, start, i - 1); firstResolveInfo = resolveInfo; firstLabel = label; start = i; } // Process last group processGroup(resolveInfos, displayInfos, start, size - 1); } return displayInfos; }
From source file:com.android.settings.users.EditUserPhotoController.java
private boolean canTakePhoto() { return mImageView.getContext().getPackageManager().queryIntentActivities( new Intent(MediaStore.ACTION_IMAGE_CAPTURE), PackageManager.MATCH_DEFAULT_ONLY).size() > 0; }
From source file:br.ufrgs.ufrgsmapas.libs.SearchBox.java
private static boolean isIntentAvailable(Context context, Intent intent) { PackageManager mgr = context.getPackageManager(); List<ResolveInfo> list = mgr.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return list.size() > 0; }
From source file:com.online.fullsail.SaveWebMedia.java
@Override protected void onPostExecute(File download) { String fileString = download.toString(); mNM.cancel(timestamp);/*from ww w . ja va 2 s. c om*/ System.gc(); String fileName = fileString.substring(fileString.lastIndexOf('/') + 1, fileString.length()); String fileExt = fileName.substring(fileName.lastIndexOf('.') + 1, fileName.length()); File downFile = new File(externalData, fileName); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(downFile), "application/" + fileExt); List<ResolveInfo> intents = this.context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (intents == null || intents.size() == 0) { intent.setDataAndType(Uri.fromFile(downFile), "video/" + fileExt); intents = this.context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (intents == null || intents.size() == 0) { intent.setDataAndType(Uri.fromFile(downFile), "image/" + fileExt); intents = this.context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (intents == null || intents.size() == 0) { intent = new Intent(Intent.ACTION_SEARCH); if (Integer.parseInt(Build.VERSION.SDK) > Build.VERSION_CODES.ECLAIR) { intent.setPackage("com.android.vending"); } intent.putExtra("query", fileExt); } } } intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent contentIntent = PendingIntent.getActivity(this.context, 0, intent, PendingIntent.FLAG_ONE_SHOT); Notification notification = null; Resources resources = this.context.getResources(); String[] mediaTypes = resources.getStringArray(R.array.media); boolean acceptedType = false; for (int i = 0; i < mediaTypes.length; i++) { if (fileExt.toLowerCase().equals(mediaTypes[i])) { acceptedType = true; } } if (acceptedType) { Bitmap preview = null; String[] videoTypes = resources.getStringArray(R.array.movFiles); for (int i = 0; i < videoTypes.length; i++) { if (fileExt.toLowerCase().equals(videoTypes[i])) { preview = getVideoFrame(fileString); } } String[] imageTypes = resources.getStringArray(R.array.movFiles); for (int i = 0; i < imageTypes.length; i++) { if (fileExt.toLowerCase().equals(imageTypes[i])) { preview = decodeBitmapFile(fileString); } } NotificationCompat.Builder builder = new NotificationCompat.Builder(this.context); builder.setTicker(this.context.getString(R.string.notify_download_complete)) .setWhen(System.currentTimeMillis()) .setContentTitle(this.context.getString(R.string.Document_complete)) .setContentText(this.context.getString(R.string.Pdf_completed, fileName)) .setSmallIcon(R.drawable.icon).setAutoCancel(true).setPriority(Notification.PRIORITY_HIGH) .setContentIntent(contentIntent); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { notification = new NotificationCompat.BigPictureStyle(builder).bigPicture(preview).build(); } else { notification = builder.build(); } } else { NotificationCompat.Builder builder = new NotificationCompat.Builder(this.context); builder.setContentTitle(this.context.getString(R.string.Document_complete)) .setContentText(this.context.getString(R.string.Pdf_completed, fileName)) .setSmallIcon(R.drawable.icon).setAutoCancel(true).setPriority(Notification.PRIORITY_HIGH) .setContentIntent(contentIntent); notification = builder.build(); } notification.flags |= Notification.FLAG_AUTO_CANCEL; mNM.notify(timestamp, notification); }
From source file:com.limemobile.app.plugin.PluginHostDelegateFragmentActivity.java
@Override public void startActivity(Intent intent) { List<ResolveInfo> resolveInfos = getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (resolveInfos == null || resolveInfos.isEmpty()) { intent.setPackage(mDelegatedActivity.getPackageName()); } else {/*ww w.j a v a2 s . c om*/ super.startActivity(intent); return; } PluginClientManager.sharedInstance(this).startActivity(this, intent); }