How to do an AUTOUPDATE to update without PlayStore in Android Studio?

2

Do any of you know how to update an application that will not be uploaded to the Play Store?

I thought that when you start the application it will verify its internal version number (Versioncode and VersionName) and compare it with a WebService and download the new apk, but what it does not really is, like power Do this, I know you can but I do not know the code.

Thank you in advance, and I hope that someone will also serve you.

    
asked by Erick Medina 18.01.2018 в 18:09
source

1 answer

1
  

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.

    
answered by 18.01.2018 в 21:25