判断微信是否存在

2022-07-16 15:36:52 浏览数 (1)

public static boolean isWeixinAvilible(Context context) { final PackageManager packageManager = context.getPackageManager();// 获取packagemanager List pinfo = packageManager.getInstalledPackages(0);// 获取所有已安装程序的包信息 if (pinfo != null) { for (int i = 0; i < pinfo.size(); i ) { String pn = pinfo.get(i).packageName; if (pn.equals(“com.tencent.mm”)) { return true; } } }

代码语言:javascript复制
    return false;
}

/**
 * 判断qq是否可用
 * 
 * @param context
 * @return
 */
public static boolean isQQClientAvailable(Context context) {
    final PackageManager packageManager = context.getPackageManager();
    List<PackageInfo> pinfo = packageManager.getInstalledPackages(0);
    if (pinfo != null) {
        for (int i = 0; i < pinfo.size(); i  ) {
            String pn = pinfo.get(i).packageName;
            if (pn.equals("com.tencent.mobileqq")) {
                return true;
            }
        }
    }
    return false;
}

0 人点赞