Android-判断QQ、微信是否安装的方法

作者: IT_xiao小巫 | 来源:发表于2015-08-10 11:13 被阅读13914次
    public static boolean isWeixinAvilible(Context context) {
            final PackageManager packageManager = context.getPackageManager();// 获取packagemanager
            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.mm")) {
                        return true;
                    }
                }
            }
    
            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;
        }
    

    相关文章

      网友评论

      本文标题:Android-判断QQ、微信是否安装的方法

      本文链接:https://www.haomeiwen.com/subject/mhriqttx.html