package com.yitong.mobile.common.config.util;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import java.util.List;
/**
Author: lee
Time: 22/9/23 10:01 AM
-
Description: 检查手机是否安装某种app
*/
public class PlatformInstallCheckUtil {/**
- 是否安装支付宝
- @param context
- @return
*/
public static boolean isAlipayAvailable(Context context) {
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.eg.android.AlipayGphone")) {
return true;
}
}
}
return false;
}
/**
- 是否安装QQ
- @param context
- @return
*/
public static boolean isQQAvailable(Context context) {
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.mobileqq")) {
return true;
}
}
}
return false;
}
/**
- 是否安装微信
- @param context
- @return
*/
public static boolean isWeChatAvailable(Context context) {
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;
}
/**
* 是否安装微博
*
* @param context
* @return
*/
public static boolean isWeiboAvailable(Context context) {
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.sina.weibo")) {
return true;
}
}
}
return false;
}
}