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:org.wso2.app.catalog.api.ApplicationManager.java
/** * Checks whether the DownloadManager is available on the device. * * @param context - Context of the calling activity. *//*from w w w . jav a 2 s . co m*/ public boolean isDownloadManagerAvailable(Context context) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setClassName(resources.getString(R.string.android_download_manager_ui_resolver), resources.getString(R.string.android_download_manager_list_resolver)); return context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY) .size() > 0; }
From source file:com.limemobile.app.plugin.PluginClientFragmentActivity.java
@Override public void startActivity(Intent intent, Bundle options) { if (mProxyActivity == null) { super.startActivity(intent, options); return;/* w w w . j a v a 2 s . c om*/ } List<ResolveInfo> resolveInfos = mContext.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (resolveInfos != null && !resolveInfos.isEmpty()) { super.startActivity(intent, options); } else { intent.setPackage(mPluginPackage.mPackageName); PluginClientManager.sharedInstance(mContext).startActivity(mContext, intent, options); } }
From source file:org.kontalk.util.SystemUtils.java
public static boolean isCallable(Context context, Intent intent) { List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return list.size() > 0; }
From source file:uk.co.tekkies.readings.fragment.PassageFragment.java
private boolean installMySword() { Analytics.UIClick(getActivity(), "opening-mysword-market"); boolean installed = false; Uri marketUri = Uri.parse("market://details?id=" + MYSWORD_PACKAGE); Intent marketIntent = new Intent(Intent.ACTION_VIEW).setData(marketUri); PackageManager pm = getActivity().getPackageManager(); List<ResolveInfo> list = pm.queryIntentActivities(marketIntent, PackageManager.MATCH_DEFAULT_ONLY); if (list.size() > 0) getActivity().startActivity(marketIntent); else {// www .j av a 2 s. c om Toast.makeText(getActivity(), R.string.sorry_no_market_installed, Toast.LENGTH_LONG).show(); } return installed; }
From source file:com.nagopy.android.mypkgs.MainActivity.java
boolean canLaunchImplicitIntent(@NonNull Intent intent) { PackageManager packageManager = getPackageManager(); return !packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY).isEmpty(); }
From source file:com.twinone.locker.ui.SettingsFragment.java
private void backgroundFromGallery() { Log.d("", "background"); Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_PICK); List<ResolveInfo> ris = getActivity().getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (ris.size() > 0) { startActivityForResult(Intent.createChooser(intent, null), IMG_REQ_CODE); } else {/*from w w w .java2s . c o m*/ Toast.makeText(getActivity(), "Error - No gallery app(?)", Toast.LENGTH_SHORT).show(); } }
From source file:com.farmerbb.taskbar.activity.ContextMenuActivity.java
@SuppressWarnings("deprecation") private void generateMenu() { if (isStartButton) { addPreferencesFromResource(R.xml.pref_context_menu_open_settings); findPreference("open_taskbar_settings").setOnPreferenceClickListener(this); findPreference("start_menu_apps").setOnPreferenceClickListener(this); if (U.launcherIsDefault(this) && FreeformHackHelper.getInstance().isInFreeformWorkspace()) { addPreferencesFromResource(R.xml.pref_context_menu_change_wallpaper); findPreference("change_wallpaper").setOnPreferenceClickListener(this); }// w w w. ja va2 s . c om if (!getIntent().getBooleanExtra("dont_show_quit", false)) { addPreferencesFromResource(R.xml.pref_context_menu_quit); findPreference("quit_taskbar").setOnPreferenceClickListener(this); } } else if (isOverflowMenu) { if (getResources().getConfiguration().screenWidthDp >= 600 && Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) setTitle(R.string.tools); else { addPreferencesFromResource(R.xml.pref_context_menu_header); findPreference("header").setTitle(R.string.tools); } addPreferencesFromResource(R.xml.pref_context_menu_overflow); findPreference("volume").setOnPreferenceClickListener(this); findPreference("system_settings").setOnPreferenceClickListener(this); findPreference("lock_device").setOnPreferenceClickListener(this); findPreference("power_menu").setOnPreferenceClickListener(this); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) findPreference("file_manager").setOnPreferenceClickListener(this); else getPreferenceScreen().removePreference(findPreference("file_manager")); } else { appName = getIntent().getStringExtra("app_name"); packageName = getIntent().getStringExtra("package_name"); componentName = getIntent().getStringExtra("component_name"); userId = getIntent().getLongExtra("user_id", 0); if (getResources().getConfiguration().screenWidthDp >= 600 && Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) setTitle(appName); else { addPreferencesFromResource(R.xml.pref_context_menu_header); findPreference("header").setTitle(appName); } SharedPreferences pref = U.getSharedPreferences(this); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && pref.getBoolean("freeform_hack", false) && !U.isGame(this, packageName)) { addPreferencesFromResource(R.xml.pref_context_menu_show_window_sizes); findPreference("show_window_sizes").setOnPreferenceClickListener(this); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { int shortcutCount = getLauncherShortcuts(); if (shortcutCount > 1) { addPreferencesFromResource(R.xml.pref_context_menu_shortcuts); findPreference("app_shortcuts").setOnPreferenceClickListener(this); } else if (shortcutCount == 1) generateShortcuts(); } final PackageManager pm = getPackageManager(); Intent homeIntent = new Intent(Intent.ACTION_MAIN); homeIntent.addCategory(Intent.CATEGORY_HOME); ResolveInfo defaultLauncher = pm.resolveActivity(homeIntent, PackageManager.MATCH_DEFAULT_ONLY); if (!packageName.contains(BuildConfig.BASE_APPLICATION_ID) && !packageName.equals(defaultLauncher.activityInfo.packageName)) { PinnedBlockedApps pba = PinnedBlockedApps.getInstance(this); if (pba.isPinned(componentName)) { addPreferencesFromResource(R.xml.pref_context_menu_pin); findPreference("pin_app").setOnPreferenceClickListener(this); findPreference("pin_app").setTitle(R.string.unpin_app); } else if (pba.isBlocked(componentName)) { addPreferencesFromResource(R.xml.pref_context_menu_block); findPreference("block_app").setOnPreferenceClickListener(this); findPreference("block_app").setTitle(R.string.unblock_app); } else { final int MAX_NUM_OF_COLUMNS = U.getMaxNumOfEntries(this); if (pba.getPinnedApps().size() < MAX_NUM_OF_COLUMNS) { addPreferencesFromResource(R.xml.pref_context_menu_pin); findPreference("pin_app").setOnPreferenceClickListener(this); findPreference("pin_app").setTitle(R.string.pin_app); } addPreferencesFromResource(R.xml.pref_context_menu_block); findPreference("block_app").setOnPreferenceClickListener(this); findPreference("block_app").setTitle(R.string.block_app); } } addPreferencesFromResource(R.xml.pref_context_menu); findPreference("app_info").setOnPreferenceClickListener(this); findPreference("uninstall").setOnPreferenceClickListener(this); } }
From source file:com.limemobile.app.plugin.PluginClientFragmentActivity.java
@Override public ComponentName startService(Intent service) { if (mProxyActivity == null) { return super.startService(service); }/* ww w . j av a2 s . c o m*/ List<ResolveInfo> resolveInfos = mContext.getPackageManager().queryIntentServices(service, PackageManager.MATCH_DEFAULT_ONLY); if (resolveInfos != null && !resolveInfos.isEmpty()) { return super.startService(service); } else { service.setPackage(mPluginPackage.mPackageName); return PluginClientManager.sharedInstance(mContext).startService(mContext, service); } }
From source file:com.amaze.filemanager.utils.Futils.java
private boolean isSelfDefault(File f, Context c) { Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(f), MimeTypes.getMimeType(f)); String s = ""; ResolveInfo rii = c.getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); if (rii != null && rii.activityInfo != null) s = rii.activityInfo.packageName; if (s.equals("com.amaze.filemanager") || rii == null) return true; else//from www . jav a2 s.com return false; }
From source file:com.github.javiersantos.piracychecker.LibraryUtils.java
private static boolean isIntentAvailable(Context ctx, Intent intent) { final PackageManager mgr = ctx.getPackageManager(); List<ResolveInfo> list = mgr.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return list != null && list.size() > 0; }