From c4682363c0a915738748bc23d23cb400600b032f Mon Sep 17 00:00:00 2001 From: CraZyLegenD Date: Sun, 21 Jun 2020 13:52:24 +0200 Subject: [PATCH] fix: version code compat --- .../com/crazylegend/crashyreporter/utils/DeviceUtils.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crashyreporter/src/main/java/com/crazylegend/crashyreporter/utils/DeviceUtils.kt b/crashyreporter/src/main/java/com/crazylegend/crashyreporter/utils/DeviceUtils.kt index 9922974..de87978 100644 --- a/crashyreporter/src/main/java/com/crazylegend/crashyreporter/utils/DeviceUtils.kt +++ b/crashyreporter/src/main/java/com/crazylegend/crashyreporter/utils/DeviceUtils.kt @@ -98,7 +98,12 @@ internal object DeviceUtils { } private fun getDeviceID(context: Context): String? = Settings.Secure.getString(context.contentResolver, Settings.Secure.ANDROID_ID) - private fun getAppVersion(context: Context) = context.packageManager.getPackageInfo(context.packageName, 0).longVersionCode + private fun getAppVersion(context: Context) = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + context.packageManager.getPackageInfo(context.packageName, 0).longVersionCode + } else { + context.packageManager.getPackageInfo(context.packageName, 0).versionCode.toLong() + } + private fun getLaunchedFromApp(context: Context): String? { val packageName: String? val localPackageManager = context.packageManager