package com.yidian.bcommon.utils

import android.content.Context
import android.content.pm.ApplicationInfo
import android.content.pm.PackageManager
import android.util.Log


/**
 * 检查APK是否安装
 */
class CheckApkExistUtil {
  companion object {
    const val weChatPkgName = "com.tencent.mm"
    const val mobileQQPkgName = "com.tencent.mobileqq"
    const val sinaBlogPkgName = "com.sina.weibo"

    fun checkApkExist(context: Context, packageName: String): Boolean {
      if (packageName.isEmpty()) return false
      val packageInfo: ApplicationInfo? = try {
        context.packageManager.getApplicationInfo(packageName, PackageManager.GET_UNINSTALLED_PACKAGES)
      } catch (e: PackageManager.NameNotFoundException) {
        null
      }
      return packageInfo != null
    }
  }
}
