- 首页 > it技术 > >
android|android 判断是否安装,微信、支付宝、qq、新浪app!
public class IsInstallWeChatOrAliPay {public IsInstallWeChatOrAliPay() {
}/**
* 检测是否安装支付宝
* @param context
* @return
*/
public static boolean checkAliPayInstalled(Context context) {Uri uri = Uri.parse("alipays://platformapi/startApp");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
ComponentName componentName = intent.resolveActivity(context.getPackageManager());
return componentName != null;
}/**
* 判断 用户是否安装微信客户端
*/
public static boolean isWeixinAvilible(Context context) {
final PackageManager packageManager = context.getPackageManager();
// 获取packagemanager
List【android|android 判断是否安装,微信、支付宝、qq、新浪app!】 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客户端
*/
public static boolean isQQClientAvailable(Context context) {
final PackageManager packageManager = context.getPackageManager();
List pinfo = packageManager.getInstalledPackages(0);
if (pinfo != null) {
for (int i = 0;
i < pinfo.size();
i++) {
String pn = pinfo.get(i).packageName;
if (pn.equalsIgnoreCase("com.tencent.qqlite") || pn.equalsIgnoreCase("com.tencent.mobileqq")) {
return true;
}
}
}
return false;
}/**
* sina
* 判断是否安装新浪微博
*/
public static boolean isSinaInstalled(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.sina.weibo")) {
return true;
}
}
}return false;
}
}
推荐阅读