How to Set and Get Application Version

Asked

Viewed 1,445 times

8

I’m almost finished my first android app, and I made a "page" of about and manually put the version number. Da para definir a versão em algum local ? e tem como obter ela dentro do programa ?

1 answer

9


To recover the app version use:

PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
String version = pInfo.versionName;

int verCode = pInfo.versionCode;

The easiest and fastest way to change the version in Android Studio is:

Press SHIFT+CTRL+ALT+S

Choose the 'Flavors' tab'

The last two fields are 'Version Code' and 'Version Name'

But you can also change by the file build.gradle:

defaultConfig {
    minSdkVersion 9
    targetSdkVersion 19
    versionCode 1
    versionName "1.0"
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.