Skip to content

Repository files navigation

AndroidAppUpdater

A simple, lightweight update checker for Android apps. It reads a JSON file you host yourself, compares the version code with the installed one, and hands you the result — you decide what dialog or snackbar to show.

Features

  • You host the JSON — GitHub raw, S3, your own server, anything reachable over HTTP
  • Forceable updates — a cancellable flag in the JSON lets you block the app until the user updates
  • No UI imposed on you — the library gives you the data, you build the dialog
  • Tiny — one class, no dependency on Play Services or any update SDK

Installation

Add it in your root build.gradle at the end of repositories:

allprojects {
  repositories {
    maven { url 'https://jitpack.io' }
  }
}

Add the dependency

dependencies {
     implementation 'com.github.p32929:AndroidAppUpdater:1.0.2'
}

Basic Usage

Steps to follow:

  • Create new new AppUpdater(context, jsonUrl, listener)
  • Execute the task
  • Do something if update is available

Code example

In your Activity or Fragment, you can add the code below:

new AppUpdater(this, "https://raw.githubusercontent.com/p32929/SomeHowTosAndTexts/master/Updater/updater.json", new UpdateListener() {
            @Override
            public void onJsonDataReceived(final UpdateModel updateModel, JSONObject jsonObject) {
                if (AppUpdater.getCurrentVersionCode(MainActivity.this) < updateModel.getVersionCode()) {
                    new AlertDialog.Builder(MainActivity.this)
                            .setTitle("Update available")
                            .setCancelable(updateModel.isCancellable())
                            .setPositiveButton("Update", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(updateModel.getUrl()));
                                    startActivity(browserIntent);
                                    finish();
                                }
                            })
                            .show();
                }
            }

            @Override
            public void onError(String error) {
                // Do something
            }
        }).execute();

the JSON data should be like below:

{
	"versionCode": 1, // Updated version code
	"cancellable": false, // If you want to force users to update the app
	"url": "http://tiny.cc/BuySellBD" // If you want users to update the app from an External URL or from the Google Play URL
}

If you add more data in the JSON file, you can get them from the jsonObject variable.

Hope you will enjoy using the library :) Thanks :)

License

MIT License — Copyright (c) 2019 Fayaz Bin Salam. See LICENSE for the full text.

Contributing

Contributions are warmly welcomed and greatly appreciated! Whether it's a bug fix, new feature, or improvement, your input helps make this project better for everyone.

Before submitting a pull request, please:

  1. Create an issue describing the feature or bug fix you'd like to work on
  2. Wait for discussion and approval to ensure alignment with project goals
  3. Fork the repository and create your feature branch
  4. Submit your pull request with a clear description of changes

This approach helps avoid duplicate efforts and ensures smooth collaboration. Thank you for considering contributing!

Share

Sharing this repository with your friends is just one click away from here

facebook twitter tumblr pocket pinterest reddit linkedin whatsapp


Support

If this saved you time, you can buy me a coffee — it keeps these projects maintained and free. Other payment options: https://p32929.github.io/SendMoney2MeV1/

Buy Me A Coffee


💼 Using this at a company?

I do fixed-price delivery work on my own projects. One invoice, one date, no hourly billing:

White-label build — this project rebranded, extended and deployed as yours $6,500 · 3 weeks
Custom app from scratch on my own stack, signed and auto-updating $12,500 · 6 weeks
Production-hardening sprint — 72 hours on this project, for your load and your security review $999
Ongoing capacity — one project-week of my time reserved every month $9,000 / month

Full details → p32929.github.io/hire · Email fayazdevinbox@uberip.com — scoping and quotes are free and I answer within one business day.

About

Lightweight Android update checker that reads a JSON file you host — supports forced updates, no Play Services

Topics

Resources

Stars

26 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages