Develop
2020.12.15 12:42
[kotlin] 코틀린 안드로이드 앱 버전/빌드 정보
조회 수 827 댓글 0
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/
-
[js] One Time Pad key generatorㅡ.,ㅡ;
-
[c] 문자열 컨트롤 함수로 만든 프로그램들..
-
[php] 피코맥스용 검색엔진 ㅋㅋ
-
[c] 파일 복사(copy) 프로그램 샘플 소스
-
[js] 실행되는 디렉토리 확인하는 스크립트..
-
[js] 한글문서로 된 259가지 자바스크립트 예제파일
-
[c] 시간 계산 하는 프로그램 소스코드
-
[c] 프로그래밍 과제..(colprint)
-
[pdf] C 국제 표준 문서
-
[js] 윈도우 시작버튼처럼 나오는 메뉴
-
[c] 싱글, 더블 링크리스트(linked list)로 만든 예제..
-
[c] 소켓주소 구조체에 대해..