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 android.content.Context;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

import android.util.Log;

public class Main {
    private static final String TAG = "CommonUtil";

    public static boolean isAppInstall(Context context, String pkg) {
        if (context == null || pkg == null) {
            return false;
        }
        try {
            PackageInfo info = context.getPackageManager().getPackageInfo(pkg, PackageManager.GET_GIDS);
            Log.d(TAG, "app info " + info.packageName);
        } catch (PackageManager.NameNotFoundException e) {
            return false;
        }
        return true;
    }
}