You can use this method:
public static boolean isOurAppDefault(Context context) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://google.com")); ResolveInfo resolveInfo = context.getPackageManager().resolveActivity(browserIntent,PackageManager.MATCH_DEFAULT_ONLY); String defaultBrowserPkg = null; if (resolveInfo != null) { if (resolveInfo.activityInfo != null) { defaultBrowserPkg = resolveInfo.activityInfo.packageName; } } return TextUtils.equals(context.getPackageName(), defaultBrowserPkg); }
This is true for some editors or browsers. Otherwise, use different Uri data for the intent.
Djek-grif
source share