Reputation: 856
Some Android devices don't have Android Market, like Korea, etc.
Is it possible to detect the existence of Android Market at runtime?
I know I can try to open a market uri first to see if there is any exception thrown. But I don't think this is a wise approach.
Upvotes: 3
Views: 669
Reputation: 11
A complete solution, that also reads the packagename by itself ...
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);
Upvotes: 1
Reputation: 1006944
I know I can try to open a market uri first to see if there is any exception thrown.
Create the ACTION_VIEW
Intent
for the Market Uri
, then use PackageManager
and queryIntentActivities()
to see if you get anything back. If that returns an empty list, you know nothing on the device handles Market Uri
values.
Upvotes: 4