Contents

조회 수 2815 댓글 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 Etc [link] 유용한 사이트 링크. hooni 2013.08.19 130949
780 Etc 베지어 곡선 (Bezier curve) file hooni 2013.08.18 239049
779 Etc [web] 제로보드 XE 템플릿에서 if문에 대해서 알아봅시다 hooni 2013.08.16 24757
778 Develop 아이 훌레시 작업중 ㅋㅋ secret hooni 2013.08.09 0
777 Develop [ios] 최신 UI 모음.. (나중에 정리할 것) secret hooni 2013.08.09 0
776 Develop [ios] UI컨트롤러 샘플코드 hooni 2013.08.08 16492
775 Develop [ios] libxml/tree.h file not found file hooni 2013.08.08 21285
774 Develop [ios] 소소한 팁 (Rect,Point,Path,URL 등) hooni 2013.08.08 32647
773 Develop [ios] Background 에서 네트워크 사용 file hooni 2013.07.22 13158
772 Develop [ios] App States file hooni 2013.07.22 14535
771 Etc 영어의 12 시제 (The twelve tenses of English) hooni 2013.07.12 17297
770 System/OS [mac] 컨텍스트(Context) 메뉴 "다음으로 열기" 내용 정리 hooni 2013.07.10 20365
Board Pagination Prev 1 ... 29 30 31 32 33 34 35 36 37 38 ... 99 Next
/ 99