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;

public class Main {
    /** Checks if a package is installed.
     * 
     * @param context Context to be used to verify the existence of the package.
     * @param packageName Package name to be searched.
     * @return true if the package is discovered; false otherwise
     */
    public static boolean isPackageInstalled(Context context, String packageName) {
        try {
            context.getPackageManager().getApplicationInfo(packageName, 0);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
}