package com.yidian.common.utils

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

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
            var packageInfo: ApplicationInfo?
            try {
                packageInfo = context.packageManager.getApplicationInfo(packageName, PackageManager.GET_UNINSTALLED_PACKAGES)
            }catch (e: PackageManager.NameNotFoundException){
                packageInfo = null
            }
            return packageInfo != null
        }
    }
}