Detect if new install or updated version (Android app)

前端 未结 8 1084
-上瘾入骨i
-上瘾入骨i 2020-12-24 06:41

I have an app on the Play Store. I want to put a requirement that if users want to use a certain part of the app, they have to invite a friend before being able to do so. Bu

8条回答
  •  粉色の甜心
    2020-12-24 06:52

    You can get the version code and version name using below code snippet

    String versionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
    
    int versionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
    

    Now you can check for the latest version and restrict as per your requirement.

提交回复
热议问题