Recently introduced Play Core library gives Version Code of the app.
// Creates instance of the manager.
val appUpdateManager = AppUpdateManagerFactory.create(context)
// Returns an intent object that you use to check for an update.
val appUpdateInfoTask = appUpdateManager.appUpdateInfo
// Checks that the platform will allow the specified type of update.
appUpdateInfoTask.addOnSuccessListener { appUpdateInfo ->
{
appUpdateInfo.availableVersionCode()
}
}
The AppUpdateManager.AppUpdateInfo() will give the latest updatable VersionCode number from Play Store.
Note that it does not give VersionName
string value.