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.theaetetuslabs.android_apkmaker.InstallActivity.java
private void tryInstallInternal() { Log.d("TAG", "signed exists? " + files.signed.exists() + ", " + files.signed.getAbsolutePath()); System.out.println(BuildConfig.APPLICATION_ID + ".apkmakerfileprovider"); Uri contentUri = FileProvider.getUriForFile(this, getPackageName() + ".apkmakerfileprovider", files.signed); grantUriPermission("com.android.packageinstaller", contentUri, Intent.FLAG_GRANT_READ_URI_PERMISSION); Intent promptInstall = getInstallIntent(); promptInstall.setData(contentUri);// w ww .j ava2 s . com List<ResolveInfo> list = getPackageManager().queryIntentActivities(promptInstall, PackageManager.MATCH_DEFAULT_ONLY); if (list.size() > 0) { startActivityForResult(promptInstall, INSTALL_REQUEST); Log.d("TAG", "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Handled content URI"); } }
From source file:com.limemobile.app.plugin.PluginHostDelegateFragmentActivity.java
@Override public void startActivity(Intent intent, Bundle options) { 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.startActivity(intent, options); return; } PluginClientManager.sharedInstance(this).startActivity(this, intent, options); }
From source file:com.android.managedprovisioning.ProfileOwnerPreProvisioningActivity.java
private boolean currentLauncherSupportsManagedProfiles() { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); PackageManager pm = getPackageManager(); ResolveInfo launcherResolveInfo = pm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); if (launcherResolveInfo == null) { return false; }/*ww w . j a v a 2 s .c om*/ try { ApplicationInfo launcherAppInfo = getPackageManager() .getApplicationInfo(launcherResolveInfo.activityInfo.packageName, 0 /* default flags */); return versionNumberAtLeastL(launcherAppInfo.targetSdkVersion); } catch (PackageManager.NameNotFoundException e) { return false; } }
From source file:com.ravi.apps.android.newsbytes.DetailsFragment.java
@Override public void onClick(View v) { // Determine which view was clicked and proceed accordingly. switch (v.getId()) { case R.id.mark_favorite_button: { // Disable mark as favorite button. mMarkAsFav.setEnabled(false);//from w ww .j a va2 s . c o m // Set the news story as favorite. mNews.setIsFavorite(1); // Create intent to add news story into database. Intent intent = new Intent(getActivity(), AddFavoriteService.class); intent.putExtra(NEWS_FAVORITE, mNews); // Send intent to start add favorite intent service. getActivity().startService(intent); break; } case R.id.read_more_button: { // Check if news story uri is valid. if (mNews.getUriStory() != null && !mNews.getUriStory().isEmpty()) { // Create implicit intent to view full news story. Intent newsIntent = new Intent(); // Set the intent action and data. newsIntent.setAction(Intent.ACTION_VIEW) .setData(Uri.parse(Utility.removeCharsFromString(mNews.getUriStory(), "\\"))); // Check if at least one app exists on the device that can handle this intent. if (getActivity().getPackageManager() .queryIntentActivities(newsIntent, PackageManager.MATCH_DEFAULT_ONLY).size() > 0) { // Pass intent to view full news story. startActivity(newsIntent); } else { // No apps exist on the device that can perform this action. // Show user message in an alert dialog. AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); alert.setTitle(getString(R.string.msg_err_dialog_title)); alert.setMessage(getString(R.string.msg_err_no_apps)); alert.setPositiveButton(getString(R.string.label_dialog_ok), null); alert.show(); } } else { // News story uri is not available. Show user message in an alert dialog. AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); alert.setTitle(getString(R.string.msg_err_dialog_title)); alert.setMessage(getString(R.string.msg_err_no_uri)); alert.setPositiveButton(getString(R.string.label_dialog_ok), null); alert.show(); } break; } case R.id.share_fab: { // Create the intent to share the news story. Intent shareIntent = Intent.createChooser( ShareCompat.IntentBuilder.from(getActivity()).setType(getString(R.string.type_share_intent)) .setSubject(getHeadline()) .setText(getSummary() + getString(R.string.msg_read_more) + getUriStory()).getIntent(), getString(R.string.action_share)); // Check if at least one app exists on the device that can handle this intent. if (getActivity().getPackageManager() .queryIntentActivities(shareIntent, PackageManager.MATCH_DEFAULT_ONLY).size() > 0) { // Pass intent to share news story. startActivity(shareIntent); } else { // No apps exist on the device that can perform this action. // Show user message in an alert dialog. AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); alert.setTitle(getString(R.string.msg_err_dialog_title)); alert.setMessage(getString(R.string.msg_err_no_apps)); alert.setPositiveButton(getString(R.string.label_dialog_ok), null); alert.show(); } break; } } }
From source file:com.limemobile.app.plugin.PluginHostDelegateFragmentActivity.java
@Override public ComponentName startService(Intent service) { List<ResolveInfo> resolveInfos = getPackageManager().queryIntentServices(service, PackageManager.MATCH_DEFAULT_ONLY); if (resolveInfos == null || resolveInfos.isEmpty()) { service.setPackage(mDelegatedActivity.getPackageName()); } else {//from ww w . j a v a 2 s . com return super.startService(service); } return PluginClientManager.sharedInstance(this).startService(this, service); }
From source file:texus.autozoneuaenew.fragments.FragmentProductDetails.java
public void showPdf() { File file = new File(ApplicationClass.PDF_FOLDER + File.separator + pdfFileName); PackageManager packageManager = ApplicationClass.getInstance().getPackageManager(); Intent testIntent = new Intent(Intent.ACTION_VIEW); testIntent.setType("application/pdf"); List list = packageManager.queryIntentActivities(testIntent, PackageManager.MATCH_DEFAULT_ONLY); Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); Uri uri = Uri.fromFile(file);//from ww w. ja va 2 s .c o m intent.setDataAndType(uri, "application/pdf"); startActivity(intent); }
From source file:com.limemobile.app.plugin.PluginHostDelegateFragmentActivity.java
@Override public boolean stopService(Intent service) { List<ResolveInfo> resolveInfos = getPackageManager().queryIntentServices(service, PackageManager.MATCH_DEFAULT_ONLY); if (resolveInfos == null || resolveInfos.isEmpty()) { service.setPackage(mDelegatedActivity.getPackageName()); } else {/*from w ww .j ava2 s .c om*/ return super.stopService(service); } return PluginClientManager.sharedInstance(this).stopService(this, service); }
From source file:com.just.agentweb.AgentWebUtils.java
static void grantPermissions(Context context, Intent intent, Uri uri, boolean writeAble) { int flag = Intent.FLAG_GRANT_READ_URI_PERMISSION; if (writeAble) { flag |= Intent.FLAG_GRANT_WRITE_URI_PERMISSION; }/*from w w w . java 2 s .c om*/ intent.addFlags(flag); List<ResolveInfo> resInfoList = context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); for (ResolveInfo resolveInfo : resInfoList) { String packageName = resolveInfo.activityInfo.packageName; context.grantUriPermission(packageName, uri, flag); } }
From source file:com.google.android.marvin.talkback.TtsDiscoveryProxyActivity.java
/** * Queries the engines in {@link #mAvailableEngines} by starting an * {@link Engine#ACTION_CHECK_TTS_DATA} activity for each engine using * {@link #startActivityForResult}./*from w w w.j a va 2s. c om*/ * * @return {@code true} if at least one activity was started. */ private boolean queryAvailableEngines() { mExpectedResults = mAvailableEngines.size(); final PackageManager pm = getPackageManager(); for (int i = 0; i < mAvailableEngines.size(); i++) { final TtsEngineInfo engine = mAvailableEngines.get(i); final Intent checkTtsDataIntent = new Intent(Engine.ACTION_CHECK_TTS_DATA); checkTtsDataIntent.setPackage(engine.name); // Use the engine index as the request code so that we can associate // activity results with their respective engines. final int requestCode = getRequestCodeForIndex(i); if (pm.resolveActivity(checkTtsDataIntent, PackageManager.MATCH_DEFAULT_ONLY) != null) { startActivityForResult(checkTtsDataIntent, requestCode); } else { mExpectedResults--; } } return mExpectedResults > 0; }
From source file:com.lee.sdk.utils.Utils.java
/** * Indicates whether the specified action can be used as an intent. This method queries the * package manager for installed packages that can respond to an intent with the specified * action. If no suitable package is found, this method returns false. * //from w ww.j a v a2 s .co m * @param context The application's environment. * @param intent The Intent action to check for availability. * * @return True if an Intent with the specified action can be sent and responded to, false * otherwise. */ public static boolean isIntentAvailable(Context context, Intent intent) { final PackageManager packageManager = context.getPackageManager(); List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return list.size() > 0; }