package com.example.base.utils

import android.content.pm.PackageManager
import com.example.base.R

object AppUtils {

    fun getAppVersionName(): String {
        return try {
            val pm = Utils.getApp().packageManager
            val pi = pm.getPackageInfo(Utils.getApp().packageName, 0)
            pi.versionName ?: ""
        } catch (e: PackageManager.NameNotFoundException) {
            e.printStackTrace()
            ""
        }
    }
    fun getAppName(): String {
        return Utils.getApp().resources.getString(R.string.app_name)
    }

    fun buildVersionNo(): Int {
        return try {
            val pm = Utils.getApp().packageManager
            val pi = pm.getPackageInfo(Utils.getApp().packageName, 0)
            pi.versionCode
        } catch (e: PackageManager.NameNotFoundException) {
            e.printStackTrace()
            0
        }
    }
}