Contents

Views 985 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print

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
No. Category Subject Author Date Views
781 Develop [js] 웹페이지에서 특정 엘리먼트 드래그, 복사, 컨텍스트메뉴, 키보드 막기 hooni 2013.11.04 30132
780 Develop [ios] 테이블뷰셀/뷰에 배경 패턴 넣기.. hooni 2013.04.23 29857
779 Develop [ios] iCloud관련 저장 디렉토리 hooni 2013.04.23 29676
778 Develop [ios] 소소한 팁 (Rect,Point,Path,URL 등) hooni 2013.08.08 29530
777 Develop [ios] Objective-C 문자열 잘라서 배열(NSArray)에 넣기 hooni 2013.04.23 29452
776 Develop [ios] NSMutableString 문자열 패턴 교환 hooni 2013.04.23 29023
775 Develop [js] JSON 컨트롤.. 재귀호출로 값 출력하기 hooni 2013.04.23 28677
774 Develop [c++] mfc 파일 한줄씩 읽기.. ㅋㅋ hooni 2013.04.23 28635
773 Develop [c] C로 구현한 CGI - 계산기 (링크리스트, 스택, 이진트리) file hooni 2003.04.23 28155
772 Develop [ios] DJBros. (DJ요맨~) file hooni 2013.04.23 28137
771 Develop [ios] Objective-C 특정 문자 찾아 제거하기 hooni 2013.04.23 28104
770 Develop [ios] 코코아 프레임워크(Cocoa Framework) 기본적인 내용~ hooni 2013.04.23 27724
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 71 Next
/ 71