android 友盟分享 判斷QQ,微信是否安裝

NO IMAGE
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;

}

轉載出處:http://www.jianshu.com/p/2a1d052b8139