Check if device has Android Market

Although the majority of the Android powered devices have the Android Market installed, there are a lot of devices that are running Android but haven’t passed the Compatibility Test Suite (CTS) because they do not comply with the Android Compatibility Definition Document (CDD). (more info here). These device may have high quality hardware and software but they haven’t the Android Market installed.

In my personal experience, these devices may lead to a large number of problems.
The easiest way to determine if a device has the Android Market installed (and has passed the CTS) is via the following method:

public static boolean hasMarket(Context ctx) {
        Intent market = new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=test"));
        PackageManager manager = ctx.getPackageManager();
        List<ResolveInfo> list = manager.queryIntentActivities(market, 0);
        for (ResolveInfo info : list)
        {
            if (info.activityInfo.packageName.startsWith("com.android."))
                return true;
        }

        return false;
    }

You may wonder why we check the package name. The answer is simple: There can be a lot of applications that can handle the “market://” view intent such as SlideMe.

Share