is Weixin App Existed - Android App

Android examples for App:Popular App

Description

is Weixin App Existed

Demo Code


//package com.java2s;
import java.util.List;
import android.content.Context;

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

public class Main {

    public static final String PACKAGE_NAME_WEIXIN = "com.tencent.mm";

    public static boolean isWeixinExisted(Context context) {
        if (checkApp(context, PACKAGE_NAME_WEIXIN)) {
            return true;
        } else {/*  w  w  w  . j  a v  a  2s  . co m*/
            return false;
        }
    }

    private static boolean checkApp(Context context, String packageName) {
        PackageManager pm = context.getPackageManager();
        List<PackageInfo> packs = pm.getInstalledPackages(0);
        for (PackageInfo pi : packs) {
            if (pi.applicationInfo.packageName.equals(packageName)) {
                return true;
            }
        }
        return false;
    }
}

Related Tutorials