조회 수 832 추천 수 0 댓글 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
번호 분류 제목 글쓴이 날짜 조회 수
25 Develop [ios] Swift 4 Dictionary 사용하기 file hooni 2018.11.29 2034
24 Develop [ios] Locale Identifiers file hooni 2018.11.29 1635
23 Develop [Javascript][Ajax] 자바스크립트 강의 산출물 file hooni 2019.10.05 711
22 Develop 링크들 보고 지울 내용 secret hooni 2019.11.21 0
21 Develop [python] 파라미터 앞에 *, ** 의 의미? (*args, **kwargs) hooni 2019.11.22 1560
20 Develop [python][django] request.cookie 읽어오기 ㅋㅋㅋ (쓰기) hooni 2019.12.06 1697
19 Develop 자주 쓰는 Docker 명령어 alias hooni 2020.01.10 270091
18 Develop [php] 3 Ways to Detect Mobile or Desktop in PHP file hooni 2020.01.28 3731
17 Develop [ios] Start developing your navigation app for CarPlay without enrollment file hooni 2020.02.22 124856
16 Develop [sh] html 안에 있는 img 다운 받는 쉘 스크립트 file hooni 2020.05.26 646
15 Develop [sh] 쉘스크립트 if 비교 연산 hooni 2020.05.26 60699
14 Develop [js] Text 값을 클립보드에 복사하기 hooni 2020.10.10 686
13 Develop [ubuntu] 우분투 18.04에 PHP5 설치하기 hooni 2020.11.14 955
» Develop [kotlin] 코틀린 안드로이드 앱 버전/빌드 정보 hooni 2020.12.15 832
11 Develop [swift] NotificationCenter 간단 예제 file hooni 2021.01.27 8125
10 Develop [swift] popToRoot 모달뷰, 네비게이션컨트롤러 한꺼번에 닫기 file hooni 2021.01.29 1392
Board Pagination Prev 1 ... 49 50 51 52 53 Next
/ 53