1. 程式人生 > >Android 檢測系統是否安裝微信,微博,QQ

Android 檢測系統是否安裝微信,微博,QQ

 /**
     * 檢測是否安裝微信
     *
     * @param context
     * @return
     */
    public static boolean isWxInstall(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的包名為:“com.tencent.mobileqq”;

微博的包名為:“

com.sina.weibo