Contents

Views 968 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print

How to Get App Version Name in Kotlin Android

Sometimes we have to get the current App version in Android to send it to our server or to show App update popup. You can use the following method to get the App Version Name in Kotlin Android.

fun GetAppVersion(context: Context): String {
var version = ""
try {
val pInfo = context.packageManager.getPackageInfo(context.packageName, 0)
version = pInfo.versionName
} catch (e: PackageManager.NameNotFoundException) {
e.printStackTrace()
}

return version
}

This is how you can call this method.

val versionName = GetAppVersion(this)

It will return the App version name in the form of “1.0” etc.



[출처] https://handyopinion.com/how-to-get-app-version-name-in-kotlin-android/



?

List of Articles
No. Category Subject Author Date Views
1161 Develop [json] 종결자 (설명과 웹, C/C++/C# 프로그램 샘플 코드) file hooni 2013.04.23 72020
1160 Etc [link] 유용한 사이트 링크. hooni 2013.08.19 71557
1159 Develop [android] keytool을 사용하여 키스토어 생성 hooni 2013.04.23 69570
1158 Develop [ios] Random Thoughts: Rand() vs. arc4random() hooni 2013.10.31 68108
1157 Develop [iphone] performSelector:withObject:afterDelay: 에 대한 내용 hooni 2013.04.23 65898
1156 Develop [Android] 2010년에 만들었던 세미나 자료. file hooni 2013.05.28 64724
1155 Develop [c#] 간단한 IPC 통신 예제 hooni 2013.04.23 63768
1154 Develop [vb] 비주얼 베이직 자격증용 ㅎㅎ hooni 2003.04.23 61519
1153 Develop [sh] 쉘스크립트 if 비교 연산 hooni 2020.05.26 60843
1152 Develop [android] Canvas를 이용해 이미지 확대/축소 하기 hooni 2013.04.23 60786
1151 Develop [vb] 비주얼 베이직 141페이지 hooni 2003.04.23 59001
1150 Develop [c#] Json 라이브러리 (System.Net.Json.dll) file hooni 2013.04.23 58572
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 98 Next
/ 98