How to determine the presence of Android Market on devices?

Some Android devices do not have Android Market, such as Korea, etc.

Is it possible to detect the existence of the Android Market at runtime?

I know that I can open the uri market first to see if there is any exception. But I do not think this is a wise approach.

+3
source share
2 answers

I know that I can try to open the uri market first to see if there is any exception thrown.

ACTION_VIEW Intent Market Uri, PackageManager queryIntentActivities(), , . , , Market Uri.

+4

, .

Context context = this;
final PackageManager packageManager = context.getPackageManager();

String packagename = this.getPackageName();

String url = "market://details?id=" + packagename;

Intent i2 = new Intent(Intent.ACTION_VIEW);
i2.setData(Uri.parse(url));

List<ResolveInfo> resolveInfo = packageManager.queryIntentActivities(i2,PackageManager.MATCH_DEFAULT_ONLY);

if (resolveInfo.size() > 0) startActivity(i2);
+1

Source: https://habr.com/ru/post/1756691/


All Articles