I thought that when you start the application, it will verify
your internal version number (Versioncode and VersionName) and compare it with a WebService
Actually, what you propose is correct, you do not even need a Web Service, when you start your application you can get the versionCode
or versionName
of the application:
PackageInfo pinfo = null;
try {
pinfo = getPackageManager().getPackageInfo(getPackageName(), 0);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
int versionCode = pinfo.versionCode;
String versionName = pinfo.versionName;
and compare it with the one defined in a configuration file that you download when you start your application:
{"versiones": {
"version": [
{
"text": "Descarga la última versión en la Play Store.",
"numVersion": "1.2",
"update": "http://www.mydomain.com/application.apk"
},
{
"text": "Descarga la última versión en la Play Store.",
"numVersion": "1.2.1",
"update": "http://www.mydomain.com/application.apk"
}
]
}
}
If the version matches, you can start the .apk download to update that you can also define in your configuration file, and even show a message.
Remember that in this case, the installation does not come from Google Playstore, the user will have to execute the .apk manually.