From 329c8db9e56d0d17fe3af4b07f18d22211c3810d Mon Sep 17 00:00:00 2001 From: MUEDSA <7676275+muedsa@users.noreply.github.com> Date: Thu, 19 Sep 2024 17:13:43 +0800 Subject: [PATCH] fix: getVersionInfo --- app/src/main/kotlin/com/muedsa/uitl/AppUtil.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/muedsa/uitl/AppUtil.kt b/app/src/main/kotlin/com/muedsa/uitl/AppUtil.kt index c2f87a8..6473230 100644 --- a/app/src/main/kotlin/com/muedsa/uitl/AppUtil.kt +++ b/app/src/main/kotlin/com/muedsa/uitl/AppUtil.kt @@ -8,7 +8,10 @@ object AppUtil { fun getVersionInfo(context: Context): String { return try { val packageInfo = context.packageManager.getPackageInfo(context.packageName, 0) - "${packageInfo.versionName}(${packageInfo.longVersionCode})" + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P) + "${packageInfo.versionName}(${packageInfo.longVersionCode})" + else + "${packageInfo.versionName}(${packageInfo.versionCode})" } catch (t: Throwable) { "" }