Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import android.content.Context;

import android.content.pm.PackageInfo;

import android.content.pm.PackageManager.NameNotFoundException;

public class Main {
    public static boolean isInstall(Context context, String packagename) {
        boolean isInstall = false;
        PackageInfo packageInfo;

        try {
            packageInfo = context.getApplicationContext().getPackageManager().getPackageInfo(packagename, 0);

        } catch (NameNotFoundException e) {
            packageInfo = null;
            e.printStackTrace();
        }
        if (packageInfo == null) {
            isInstall = false;
        } else {
            isInstall = true;
        }
        return isInstall;
    }
}