Contents

조회 수 2806 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

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
번호 분류 제목 글쓴이 날짜 조회 수
781 Develop [linux] CentOS Apache 웹서버에 HTTPS 적용 hooni 2015.10.23 2082
780 System/OS [linux] CentOS Apache Httpd에 https 적용 hooni 2014.03.05 5328
779 System/OS [linux] CentOS 6.x Cati 설치 (yum) hooni 2014.01.17 49582
778 System/OS [linux] CentOS 6.5 에서 "Bringing up interface eth0: Determining if ip address 121.78.127.197 is already in use for device eth0..." hooni 2014.04.05 7346
777 System/OS [linux] awk 명령어 hooni 2014.03.11 5993
776 System/OS [linux] APM(apache, php, mysql) + gd 설치순서.. hooni 2003.04.23 20064
775 System/OS [linux] apache, php, jsp 환경설정하기.. hooni 2003.04.23 16140
774 System/OS [linux] /etc/fstab 설정 방법.. ㅋㅋ hooni 2013.04.23 13136
773 Etc [link] 유용한 사이트 링크. hooni 2013.08.19 130002
772 Etc [link] iOS(아이폰) 개발 관련 ㅋㅋ hooni 2013.04.23 22633
771 Develop [lego] 세그웨이 이것만 볼것.. ㅎㅎ file hooni 2013.04.23 36843
» Develop [kotlin] 코틀린 안드로이드 앱 버전/빌드 정보 hooni 2020.12.15 2806
Board Pagination Prev 1 ... 29 30 31 32 33 34 35 36 37 38 ... 99 Next
/ 99