Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.util.List;

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;

public class Main {

    public static boolean isPlayStoreInstalled(Context context) {
        if (null == context)
            return false;

        try {

            Intent market = new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=dummy"));
            PackageManager manager = context.getPackageManager();
            List<ResolveInfo> list = manager.queryIntentActivities(market, 0);

            return list.size() > 0;
        } catch (Exception e) {
            return false;
        }
    }
}