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
번호 분류 제목 글쓴이 날짜 조회 수
85 Develop [c] 기막힌 정렬 코드 ㅋㄷ file hooni 2015.10.13 2390
84 Develop [ios] 오브젝티브C→스위프트, 코드 변환 손쉽게 file hooni 2015.08.07 2369
83 Develop [ios] Crashlytics, Fabfic 설치/설정 hooni 2016.07.21 2356
82 Develop 리팩토링 계획안 file hooni 2017.05.15 2344
81 Develop [ios] iOS 앱 아이콘을 만드는 유틸 file hooni 2015.01.03 2317
80 Develop [ios] UIView 계층구조 hooni 2015.01.03 2316
79 System/OS [linux] yum 업데이트 시 커널 제외하기 hooni 2014.09.11 2314
78 Develop [ios] UIWebView를 이용한 로컬 HTML 파일 표시 file hooni 2015.01.02 2300
77 Etc 수리통계학 : 표본공간과 사상-1 hooni 2015.04.20 2282
76 Develop [ios] 비디오,네트워크,소셜로그인 테스트 file hooni 2017.04.04 2271
75 Develop [git] 쉬운 버전관리 Git 설명 hooni 2015.08.18 2263
74 Develop [ios] VIN Scanner (VIN barcode) 스캐너 file hooni 2017.09.16 2262
Board Pagination Prev 1 ... 87 88 89 90 91 92 93 94 95 96 ... 99 Next
/ 99