Get Android App Version (GAAV)

I just want to display my version name on my login screen, but it always returns null. I have defined my versionName in my app's gradle build, and I call it like this, is this correct?

BuildConfig.VERSION_NAME

Solution

The above method is wrong, it should be like this:

PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0 );
String version = pInfo.versionName; //Version Name 
int verCode = pInfo.versionCode; //Version Code

Post a Comment

Previous Next

نموذج الاتصال