Contents

Views 987 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
145 Develop [matlab] ZigZag-Scanning (2-D Array) file hooni 2016.10.15 2116
144 Develop [c#] MS IE(Internet Explorer) 툴바 버튼 예제 2003/2005 두가지 버전 secret hooni 2013.04.23 2090
143 Develop [c#] mfc 기반의 웹서비스 서버/클라이언트 샘플과 예제 소스 secret hooni 2013.04.23 2073
142 Develop [swift] UIView에서 subview 찾기 hooni 2022.12.09 2061
141 Develop [ios] 웹뷰 history.back() ㅋㄷ file hooni 2016.06.27 2040
140 Develop [iOS] 시뮬레이터에 푸시 알림을 보내는 방법 file hooni 2021.10.13 2015
139 Develop [android] 가속도 센서를 이용한 흔듦(Shake) 감지 file hooni 2014.11.04 2005
138 Develop [ios] Objective-C 에서 자주 사용하는 수학 함수와 유용한 Define hooni 2014.08.08 1996
137 Develop [iOS] Xcode 불필요한 캐시 삭제하기 hooni 2021.10.12 1984
136 Develop [ios] 카메라 사용 권한 확인해서 분기하는 방법 hooni 2015.02.26 1959
135 Develop [ios] Xcode cannot run using the selected device hooni 2014.08.14 1926
134 Develop [php] mysql_ 과 mysqli_ 의 차이 hooni 2017.12.01 1850
Board Pagination Prev 1 ... 54 55 56 57 58 59 60 61 62 63 ... 71 Next
/ 71