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 System/OS [linux] 스케쥴링 순서(nice) 변경하기 hooni 2003.04.23 13373
780 Develop [c] 네트워크 트래릭 모니터링.. 졸업작품.. 2 file hooni 2013.04.23 13348
779 Develop [c++] 기초강좌 #03(함수의 매개변수 전달) hooni 2003.04.23 13340
778 System/OS [sql] alter table 쿼리 예제 hooni 2003.04.23 13314
777 System/OS [linux] 파일내 문자열 찾아 바꾸기 hooni 2013.04.23 13297
776 System/OS [mac] Charlesproxy 간단한 설정 내용~ hooni 2013.11.12 13262
775 System/OS [linux] 간단한 NAT 설정 script hooni 2003.04.23 13258
774 System/OS [linux] 데스크탑환경(GNOME/KDE) 바꾸기.. hooni 2003.04.23 13254
773 Develop Mac OS 에 Jenkins 설치하기 (Homebrew) 2 file hooni 2017.03.15 13250
772 System/OS [linux] DNS(Domain Name System) 설치, 설정 hooni 2003.04.23 13239
771 System/OS [linux] 쉘 스크립트 (Shell Script) hooni 2003.04.23 13200
770 System/OS [linux] root도 삭제하지 못하는 파일 속성 hooni 2003.04.23 13168
Board Pagination Prev 1 ... 29 30 31 32 33 34 35 36 37 38 ... 99 Next
/ 99