Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.content.Context;

import android.content.pm.PackageInfo;

import android.text.TextUtils;

public class Main {

    public static boolean checkAppInstalled(Context context, String packetName) {
        boolean isInstalled = false;
        if (TextUtils.isEmpty(packetName))
            return isInstalled;
        PackageInfo packageInfo;
        try {
            packageInfo = context.getPackageManager().getPackageInfo(packetName, 0);

        } catch (Exception e) {
            packageInfo = null;
            // e.printStackTrace();
        }
        if (packageInfo == null) {
            isInstalled = false;
        } else {
            isInstalled = true;
        }

        return isInstalled;
    }
}