Easy to setup library for Android-Update-Server that manages updates for your Android app which cannot be distributed via Google Play or you just simply don't want to use it.
Set-up your own instance of Android-Update-Server
Add Android App to same Firebase project which you are using for Update Server
Include this library in your project
Add it to your build.gradle with:
allprojects { repositories { maven { url "https://jitpack.io" } } }
and:
dependencies { implementation 'com.github.P1-Ro:Android-Update-Lib:1.1.0' }
Set
urlandapiKeyof your server in yourstrings.xml
<stringname="update_url"translatable="false">URL_HERE</string>
<stringname="update_api_key"translatable="false">API_KEY_HERE</string> Initialize the Updater in your application’s main onCreate method:
importsk.p1ro.Updater;
publicclassMainApplicationextendsApplication {
@OverridepublicvoidonCreate() {
super.onCreate();
Updater.init(this);
}
}After you upload new version to update server users will get notified about new version automatically via notification.
If you want to allow user to check for updates themselves you can have two options.
Install update automatically right after check like this:
Buttonbutton = findViewById(R.id.updateButton);
button.setOnClickListener(e -> UpdateUtil.checkAndInstallUpdate(this))You can control individual step when to do one of update steps :
publicstaticvoidinstallUpdate(Contextcontext) {
checkUpdate(context, shouldInstall -> {
if (shouldInstall) {
// you can display some dialog heredownloadUpdate(context, callback -> {
// you can display some dialog hereinstallUpdate(context);
});
}
});
}If you want to translate messages you can do so by overriding following strings in your strings.xml
<stringname="update_check">Checking updates</string> <stringname="update_wait_please">This can take a while…</string> <stringname="update_version">New version %1$s is available</string> <stringname="update_title">Update available</string> <stringname="update_latest_version">You have latest version</string>