Source:
public static void visitInExternalBrowser(final Context context, Uri uri) { final Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(uri); final PackageManager pm = context.getPackageManager(); final ResolveInfo mInfo = pm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); final List<ComponentName> preferredActivities = new ArrayList<ComponentName>(); final IntentFilter filter = new IntentFilter(Intent.ACTION_VIEW); final List<IntentFilter> filters = new ArrayList<IntentFilter>(); filters.add(filter); pm.getPreferredActivities(filters, preferredActivities, mInfo.activityInfo.packageName); if (!preferredActivities.isEmpty() && !mInfo.activityInfo.packageName.startsWith(context.getPackageName())) { context.startActivity(intent); return; } List<ResolveInfo> resInfo = pm.queryIntentActivities(intent, 0); if (!resInfo.isEmpty()) { List<Intent> browserIntents = new ArrayList<Intent>(); for (ResolveInfo resolveInfo : resInfo) { String packageName = resolveInfo.activityInfo.packageName; if (packageName.startsWith(context.getPackageName())) { continue; } Intent newIntent = new Intent(Intent.ACTION_VIEW); newIntent.setData(uri); newIntent.setPackage(packageName); browserIntents.add(newIntent); } if (browserIntents.size() > 0) { Intent chooserIntent = Intent.createChooser(browserIntents.remove(browserIntents.size() - 1), null); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, browserIntents.toArray(new Parcelable[]{})); context.startActivity(chooserIntent); return; } } Toast.makeText(context, R.string.error_can_not_process_link, Toast.LENGTH_LONG).show(); }

Target:
public static void visitInExternalBrowser(final Context context, Uri uri) { final Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(uri); final PackageManager pm = context.getPackageManager(); final ResolveInfo mInfo = pm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); final List<ComponentName> preferredActivities = new ArrayList<ComponentName>(); final IntentFilter filter = new IntentFilter(Intent.ACTION_VIEW); final List<IntentFilter> filters = new ArrayList<IntentFilter>(); filters.add(filter); pm.getPreferredActivities(filters, preferredActivities, mInfo.activityInfo.packageName); if (!preferredActivities.isEmpty() && !mInfo.activityInfo.packageName.startsWith(APPS_PACKAGE_PREFIX)) { context.startActivity(intent); return; } List<ResolveInfo> resInfo = pm.queryIntentActivities(intent, 0); if (!resInfo.isEmpty()) { List<Intent> browserIntents = new ArrayList<Intent>(); for (ResolveInfo resolveInfo : resInfo) { String packageName = resolveInfo.activityInfo.packageName; if (packageName.startsWith(APPS_PACKAGE_PREFIX)) { continue; } Intent newIntent = new Intent(Intent.ACTION_VIEW); newIntent.setData(uri); newIntent.setPackage(packageName); browserIntents.add(newIntent); } if (browserIntents.size() > 0) { Intent chooserIntent = Intent.createChooser(browserIntents.remove(browserIntents.size() - 1), null); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, browserIntents.toArray(new Parcelable[]{})); context.startActivity(chooserIntent); return; } } Toast.makeText(context, R.string.error_can_not_process_link, Toast.LENGTH_LONG).show(); }