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.hacktx.android.activities.MainActivity.java
private boolean isSlackInstalled() { final PackageManager packageManager = getPackageManager(); Intent intent = packageManager.getLaunchIntentForPackage("com.Slack"); if (intent == null) { return false; }//from w w w . jav a 2s .c o m List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return list.size() > 0; }
From source file:com.limemobile.app.plugin.PluginHostDelegateFragmentActivity.java
@Override public boolean bindService(Intent service, ServiceConnection conn, int flags) { List<ResolveInfo> resolveInfos = getPackageManager().queryIntentServices(service, PackageManager.MATCH_DEFAULT_ONLY); if (resolveInfos == null || resolveInfos.isEmpty()) { service.setPackage(mDelegatedActivity.getPackageName()); } else {/*from www .j a v a 2 s . c o m*/ return super.bindService(service, conn, flags); } return PluginClientManager.sharedInstance(this).bindService(this, service, conn, flags); }
From source file:com.demo.firebase.MainActivity.java
@AfterPermissionGranted(RC_STORAGE_PERMS) private void launchCamera() { Log.d(TAG, "launchCamera"); // Check that we have permission to read images from external storage. String perm = Manifest.permission.WRITE_EXTERNAL_STORAGE; if (!EasyPermissions.hasPermissions(this, perm)) { EasyPermissions.requestPermissions(this, getString(R.string.rationale_storage), RC_STORAGE_PERMS, perm); return;/*from w ww .ja v a 2 s. c om*/ } // Choose file storage location, must be listed in res/xml/file_paths.xml File dir = new File(Environment.getExternalStorageDirectory() + "/photos"); File file = new File(dir, UUID.randomUUID().toString() + ".jpg"); try { // Create directory if it does not exist. if (!dir.exists()) { dir.mkdir(); } boolean created = file.createNewFile(); Log.d(TAG, "file.createNewFile:" + file.getAbsolutePath() + ":" + created); } catch (IOException e) { Log.e(TAG, "file.createNewFile" + file.getAbsolutePath() + ":FAILED", e); } // Create content:// URI for file, required since Android N // See: https://developer.android.com/reference/android/support/v4/content/FileProvider.html mFileUri = FileProvider.getUriForFile(this, "com.google.firebase.quickstart.firebasestorage.fileprovider", file); // Create and launch the intent Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, mFileUri); // Grant permission to camera (this is required on KitKat and below) List<ResolveInfo> resolveInfos = getPackageManager().queryIntentActivities(takePictureIntent, PackageManager.MATCH_DEFAULT_ONLY); for (ResolveInfo resolveInfo : resolveInfos) { String packageName = resolveInfo.activityInfo.packageName; grantUriPermission(packageName, mFileUri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION); } // Start picture-taking intent startActivityForResult(takePictureIntent, RC_TAKE_PICTURE); }
From source file:com.limemobile.app.plugin.PluginClientFragmentActivity.java
@Override public void startActivityForResult(Intent intent, int requestCode) { if (mProxyActivity == null) { super.startActivityForResult(intent, requestCode); return;/*from w w w. ja v a 2 s.co m*/ } List<ResolveInfo> resolveInfos = mContext.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (resolveInfos != null && !resolveInfos.isEmpty()) { super.startActivityForResult(intent, requestCode); } else { intent.setPackage(mPluginPackage.mPackageName); PluginClientManager.sharedInstance(mContext).startActivityForResult(mContext, intent, requestCode); } }
From source file:com.tortel.deploytrack.MainActivity.java
/** * Check if there is an app available to handle an intent *//* w w w. ja v a2s. c om*/ private boolean isAvailable(Intent intent) { final PackageManager mgr = getPackageManager(); List<ResolveInfo> list = mgr.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return list.size() > 0; }
From source file:com.ijsbrandslob.appirater.Appirater.java
public void launchPlayStore() { PackageManager packageManager = mContext.getPackageManager(); Uri marketUri = Uri.parse(String.format("market://details?id=%s", mContext.getPackageName())); Intent marketIntent = new Intent(Intent.ACTION_VIEW).setData(marketUri); List<?> list = packageManager.queryIntentActivities(marketIntent, PackageManager.MATCH_DEFAULT_ONLY); if (list.size() > 0) { mContext.startActivity(marketIntent); } else {/* w w w. j a v a2 s . co m*/ Uri webUri = Uri.parse( String.format("http://play.google.com/store/apps/details?id=%s", mContext.getPackageName())); Intent webIntent = new Intent(Intent.ACTION_VIEW).setData(webUri); mContext.startActivity(webIntent); } }
From source file:com.airk.interpolatordiagram.app.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (mDrawerToggle.onOptionsItemSelected(item)) { return true; }/*from w w w . j a v a2s . c o m*/ if (item.getItemId() == R.id.action_rate) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("market://details?id=com.airk.interpolatordiagram.app")); PackageManager pm = getPackageManager(); List<ResolveInfo> list = pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (list.size() <= 0) { intent.setData(Uri.parse("https://market.android.com/details?id=com.airk.interpolatordiagram.app")); } startActivity(intent); } else if (item.getItemId() == R.id.action_about) { new AboutFragmentDialog().show(getSupportFragmentManager(), "about"); } return super.onOptionsItemSelected(item); }
From source file:bolts.AppLinkNavigation.java
/** * Performs the navigation./*w ww.ja va 2s .c om*/ * * @param context the Context from which the navigation should be performed. * @return the {@link NavigationResult} performed by navigating. */ public NavigationResult navigate(Context context) { PackageManager pm = context.getPackageManager(); Bundle finalAppLinkData = buildAppLinkDataForNavigation(context); Intent eligibleTargetIntent = null; for (AppLink.Target target : getAppLink().getTargets()) { Intent targetIntent = new Intent(Intent.ACTION_VIEW); if (target.getUrl() != null) { targetIntent.setData(target.getUrl()); } else { targetIntent.setData(appLink.getSourceUrl()); } targetIntent.setPackage(target.getPackageName()); if (target.getClassName() != null) { targetIntent.setClassName(target.getPackageName(), target.getClassName()); } targetIntent.putExtra(AppLinks.KEY_NAME_APPLINK_DATA, finalAppLinkData); ResolveInfo resolved = pm.resolveActivity(targetIntent, PackageManager.MATCH_DEFAULT_ONLY); if (resolved != null) { eligibleTargetIntent = targetIntent; break; } } Intent outIntent = null; NavigationResult result = NavigationResult.FAILED; if (eligibleTargetIntent != null) { outIntent = eligibleTargetIntent; result = NavigationResult.APP; } else { // Fall back to the web if it's available Uri webUrl = getAppLink().getWebUrl(); if (webUrl != null) { JSONObject appLinkDataJson; try { appLinkDataJson = getJSONForBundle(finalAppLinkData); } catch (JSONException e) { sendAppLinkNavigateEventBroadcast(context, eligibleTargetIntent, NavigationResult.FAILED, e); throw new RuntimeException(e); } webUrl = webUrl.buildUpon() .appendQueryParameter(AppLinks.KEY_NAME_APPLINK_DATA, appLinkDataJson.toString()).build(); outIntent = new Intent(Intent.ACTION_VIEW, webUrl); result = NavigationResult.WEB; } } sendAppLinkNavigateEventBroadcast(context, outIntent, result, null); if (outIntent != null) { context.startActivity(outIntent); } return result; }
From source file:com.limemobile.app.plugin.PluginClientFragmentActivity.java
@Override public void startActivityForResult(Intent intent, int requestCode, Bundle options) { if (mProxyActivity == null) { super.startActivityForResult(intent, requestCode, options); return;/* w w w .jav a 2s. c o m*/ } List<ResolveInfo> resolveInfos = mContext.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (resolveInfos != null && !resolveInfos.isEmpty()) { super.startActivityForResult(intent, requestCode, options); } else { intent.setPackage(mPluginPackage.mPackageName); PluginClientManager.sharedInstance(mContext).startActivityForResult(mContext, intent, requestCode, options); } }
From source file:com.adguard.android.commons.BrowserUtils.java
private static ComponentName getYandexBrowser(Context context, String action) { Intent mainIntent = new Intent(); mainIntent.setAction(action);//from ww w . jav a2 s . c om for (String packageName : yandexBrowserPackageList) { mainIntent.setPackage(packageName); List<ResolveInfo> installedPackages = context.getPackageManager().queryIntentActivities(mainIntent, PackageManager.MATCH_DEFAULT_ONLY); if (!installedPackages.isEmpty()) { ResolveInfo resolveInfo = installedPackages.get(0); return new ComponentName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name); } } return null; }