Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.List;

import android.content.Context;

import android.content.Intent;

import android.content.pm.PackageManager;

import android.content.pm.ResolveInfo;

public class Main {
    public static boolean isApkInstalled(Context context) {
        PackageManager pm = context.getPackageManager();

        //      Intent intent = new Intent(Intent.ACTION_MAIN, null);
        //      intent.addCategory(Intent.CATEGORY_DEFAULT);
        //      intent.setPackage("com.cnnct.zfwgpy");
        Intent intent = new Intent();
        intent.setPackage("com.cnnct.zfwgpy");
        List<ResolveInfo> apps = pm.queryIntentActivities(intent, 0);
        if (apps != null && apps.size() > 0) {
            return true;
        }
        return false;
    }
}