Contents

조회 수 827 댓글 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/



?

  1. [c] 파일명 또는 특정 패턴을 적용

    Date2016.08.03 CategoryDevelop Byhooni Views759
    Read More
  2. [Android Error] The number of method references in a .dex file cannot exceed 64K

    Date2016.11.10 CategoryDevelop Byhooni Views760
    Read More
  3. [linux] CentOS Apache 웹서버에 HTTPS 적용

    Date2015.10.23 CategoryDevelop Byhooni Views790
    Read More
  4. [macos] How to Fix ‘You Shut Down Your Computer Because of a Problem’

    Date2022.06.01 CategorySystem/OS Byhooni Views794
    Read More
  5. [io] Apple Watch, Today Extension 앱ID 설정

    Date2016.04.20 CategoryDevelop Byhooni Views801
    Read More
  6. OCB5 Injection 앗싸뵹! ㅋㅋ

    Date2014.07.01 CategoryAlgorithm Byhooni Views807
    Read More
  7. [linux] The Ultimate Wget Download Guide With 15 Awesome Examples

    Date2020.05.26 CategorySystem/OS Byhooni Views810
    Read More
  8. [js] e.stopPropagation() VS e.preventDefault ()

    Date2015.04.14 CategoryDevelop Byhooni Views813
    Read More
  9. [c] 기막힌 정렬 코드 ㅋㄷ

    Date2015.10.13 CategoryDevelop Byhooni Views814
    Read More
  10. [android] 초간단 얼럿 (AlertDialog)

    Date2016.10.21 CategoryDevelop Byhooni Views815
    Read More
  11. 사이버보안실무 수업 메모

    Date2017.03.30 CategoryEtc Byhooni Views818
    Read More
  12. [ios] 비동기 블럭 코드 예제

    Date2014.11.21 CategoryDevelop Byhooni Views825
    Read More
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 98 Next
/ 98