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:net.ddns.mlsoftlaberge.contactslist.ui.ContactAdminFragment.java
public void openaddress(String address) { final Intent viewIntent = new Intent(Intent.ACTION_VIEW, constructGeoUri(address)); // A PackageManager instance is needed to verify that there's a default app // that handles ACTION_VIEW and a geo Uri. final PackageManager packageManager = getActivity().getPackageManager(); // Checks for an activity that can handle this intent. Preferred in this // case over Intent.createChooser() as it will still let the user choose // a default (or use a previously set default) for geo Uris. if (packageManager.resolveActivity(viewIntent, PackageManager.MATCH_DEFAULT_ONLY) != null) { startActivity(viewIntent);//from w w w . j a va 2s.c om } else { // If no default is found, displays a message that no activity can handle // the view button. Toast.makeText(getActivity(), R.string.no_intent_found, Toast.LENGTH_SHORT).show(); } }
From source file:com.igniva.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.igniva.filemanager") || rii == null) return true; else//from w ww . j a v a2 s. com return false; }
From source file:hku.fyp14017.blencode.ui.controller.LookController.java
public boolean checkIfPocketPaintIsInstalled(Intent intent, final Activity activity) { // Confirm if Pocket Paint is installed else start dialog -------------------------- List<ResolveInfo> packageList = activity.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (packageList.size() <= 0) { AlertDialog.Builder builder = new CustomAlertDialogBuilder(activity); builder.setTitle(hku.fyp14017.blencode.R.string.pocket_paint_not_installed_title); builder.setMessage(hku.fyp14017.blencode.R.string.pocket_paint_not_installed).setCancelable(false) .setPositiveButton(hku.fyp14017.blencode.R.string.yes, new DialogInterface.OnClickListener() { @Override//from w w w .j a va2 s . c o m public void onClick(DialogInterface dialog, int id) { Intent downloadPocketPaintIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.POCKET_PAINT_DOWNLOAD_LINK)); activity.startActivity(downloadPocketPaintIntent); } }).setNegativeButton(hku.fyp14017.blencode.R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); return false; } return true; }
From source file:org.catrobat.catroid.ui.controller.LookController.java
public boolean checkIfPocketPaintIsInstalled(Intent intent, final Activity activity) { // Confirm if Pocket Paint is installed else start dialog -------------------------- List<ResolveInfo> packageList = activity.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (packageList.size() <= 0) { AlertDialog.Builder builder = new CustomAlertDialogBuilder(activity); builder.setTitle(R.string.pocket_paint_not_installed_title); builder.setMessage(R.string.pocket_paint_not_installed).setCancelable(false) .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @Override/*w w w .ja v a 2s . co m*/ public void onClick(DialogInterface dialog, int id) { Intent downloadPocketPaintIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.POCKET_PAINT_DOWNLOAD_LINK)); activity.startActivity(downloadPocketPaintIntent); } }).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); return false; } return true; }
From source file:com.brewcrewfoo.performance.activities.PCSettings.java
public static boolean isDownloadManagerAvailable(Context context) { try {//from w w w .j a va2 s. com if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) { return false; } Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setClassName("com.android.providers.downloads.ui", "com.android.providers.downloads.ui.DownloadList"); List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return list.size() > 0; } catch (Exception e) { return false; } }
From source file:com.android.mylauncher3.allapps.AllAppsGridAdapter.java
public AllAppsGridAdapter(Launcher launcher, AlphabeticalAppsList apps, View.OnTouchListener touchListener, View.OnClickListener iconClickListener, View.OnLongClickListener iconLongClickListener) { Resources res = launcher.getResources(); mLauncher = launcher;//from ww w. j a v a 2 s.co m mApps = apps; mEmptySearchMessage = res.getString(R.string.all_apps_loading_message); mGridSizer = new GridSpanSizer(); mGridLayoutMgr = new AppsGridLayoutManager(launcher); mGridLayoutMgr.setSpanSizeLookup(mGridSizer); mItemDecoration = new GridItemDecoration(); mLayoutInflater = LayoutInflater.from(launcher); mTouchListener = touchListener; mIconClickListener = iconClickListener; mIconLongClickListener = iconLongClickListener; mSectionNamesMargin = res.getDimensionPixelSize(R.dimen.all_apps_grid_view_start_margin); mSectionHeaderOffset = res.getDimensionPixelSize(R.dimen.all_apps_grid_section_y_offset); mSectionTextPaint = new Paint(); mSectionTextPaint.setTextSize(res.getDimensionPixelSize(R.dimen.all_apps_grid_section_text_size)); mSectionTextPaint.setColor(res.getColor(R.color.all_apps_grid_section_text_color)); mSectionTextPaint.setAntiAlias(true); mPredictedAppsDividerPaint = new Paint(); mPredictedAppsDividerPaint.setStrokeWidth(Utilities.pxFromDp(1f, res.getDisplayMetrics())); mPredictedAppsDividerPaint.setColor(0x1E000000); mPredictedAppsDividerPaint.setAntiAlias(true); mPredictionBarDividerOffset = (-res.getDimensionPixelSize(R.dimen.all_apps_prediction_icon_bottom_padding) + res.getDimensionPixelSize(R.dimen.all_apps_icon_top_bottom_padding)) / 2; // Resolve the market app handling additional searches PackageManager pm = launcher.getPackageManager(); ResolveInfo marketInfo = pm.resolveActivity(createMarketSearchIntent(""), PackageManager.MATCH_DEFAULT_ONLY); if (marketInfo != null) { mMarketAppName = marketInfo.loadLabel(pm).toString(); } }
From source file:aerizostudios.com.cropshop.MainActivity.java
public void like_facebook(View v) { final String urlFb = "fb://page/" + "430860500445507"; Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(urlFb));//from w ww .ja va 2s.c o m // If a Facebook app is installed, use it. Otherwise, launch // a browser final PackageManager packageManager = getPackageManager(); List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (list.size() == 0) { final String urlBrowser = "https://www.facebook.com/" + "cropshopofficial"; intent.setData(Uri.parse(urlBrowser)); } startActivity(intent); }
From source file:com.lite.android.launcher3.allapps.AllAppsGridAdapter.java
public AllAppsGridAdapter(Launcher launcher, AlphabeticalAppsList apps, View.OnTouchListener touchListener, View.OnClickListener iconClickListener, View.OnLongClickListener iconLongClickListener) { Resources res = launcher.getResources(); mLauncher = launcher;/*from w w w . ja v a 2 s . c o m*/ mApps = apps; mEmptySearchMessage = res.getString(R.string.all_apps_loading_message); mGridSizer = new GridSpanSizer(); mGridLayoutMgr = new AppsGridLayoutManager(launcher); mGridLayoutMgr.setSpanSizeLookup(mGridSizer); mItemDecoration = new GridItemDecoration(); mLayoutInflater = LayoutInflater.from(launcher); mTouchListener = touchListener; mIconClickListener = iconClickListener; mIconLongClickListener = iconLongClickListener; mSectionNamesMargin = mSectionStrategy == AllAppsContainerView.SECTION_STRATEGY_GRID ? res.getDimensionPixelSize(R.dimen.all_apps_grid_view_start_margin) : res.getDimensionPixelSize(R.dimen.all_apps_grid_view_start_margin_with_sections); mAllAppsTextColor = mGridTheme == AllAppsContainerView.GRID_THEME_DARK ? res.getColor(R.color.quantum_panel_text_color_dark) : res.getColor(R.color.quantum_panel_text_color); mSectionHeaderOffset = res.getDimensionPixelSize(R.dimen.all_apps_grid_section_y_offset); mSectionTextPaint = new Paint(); mSectionTextPaint.setTextSize(res.getDimensionPixelSize(R.dimen.all_apps_grid_section_text_size)); int sectionTextColorId = mGridTheme == AllAppsContainerView.GRID_THEME_DARK ? R.color.all_apps_grid_section_text_color_dark : R.color.all_apps_grid_section_text_color; mSectionTextPaint.setColor(res.getColor(sectionTextColorId)); mSectionTextPaint.setAntiAlias(true); mPredictedAppsDividerPaint = new Paint(); mPredictedAppsDividerPaint.setStrokeWidth(Utilities.pxFromDp(1f, res.getDisplayMetrics())); mPredictedAppsDividerPaint.setColor(0x1E000000); mPredictedAppsDividerPaint.setAntiAlias(true); mPredictionBarDividerOffset = res.getDimensionPixelSize(R.dimen.all_apps_prediction_bar_divider_offset); // Resolve the market app handling additional searches PackageManager pm = launcher.getPackageManager(); ResolveInfo marketInfo = pm.resolveActivity(createMarketSearchIntent(""), PackageManager.MATCH_DEFAULT_ONLY); if (marketInfo != null) { mMarketAppName = marketInfo.loadLabel(pm).toString(); } mRemoteFolderManager = launcher.getRemoteFolderManager(); }
From source file:com.quarterfull.newsAndroid.NewsDetailActivity.java
private boolean isChromeDefaultBrowser() { Intent browserIntent = new Intent("android.intent.action.VIEW", Uri.parse("http://")); ResolveInfo resolveInfo = getPackageManager().resolveActivity(browserIntent, PackageManager.MATCH_DEFAULT_ONLY); Log.v(TAG, "Default Browser is: " + resolveInfo.loadLabel(getPackageManager()).toString()); return (resolveInfo.loadLabel(getPackageManager()).toString().contains("Chrome")); }
From source file:com.linkbubble.util.Util.java
static public String getDefaultLauncherPackage(PackageManager packageManager) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); ResolveInfo resolveInfo = packageManager.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); if (resolveInfo != null && resolveInfo.activityInfo != null) { if (resolveInfo.activityInfo.packageName.equals("android") == false) { //setDefaultLauncherPreference.setSummary(R.string.not_default_youtube_app); return resolveInfo.activityInfo.packageName; }/*from www.j av a2 s . co m*/ } return null; }