Git Product home page Git Product logo

inappupdater's Introduction

Build Status Android Arsenal API License: MIT

InAppUpdater

Android Library to easily implement in-app updates

✏️ Usage

Step 1: Add it in your root build.gradle

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

Step 2: Add the dependency

dependencies {
    implementation 'com.github.SanojPunchihewa:InAppUpdater:1.0.5'
}

Step 3: Initialize the UpdateManager

Declare the UpdateManager in your Activity

    // Declare the UpdateManager
    UpdateManager mUpdateManager;

Initialize the UpdateManager in your onCreate method of the Activity

    // Initialize the Update Manager with the Activity and the Update Mode
    mUpdateManager = UpdateManager.Builder(this).mode(UpdateManagerConstant.FLEXIBLE);
    mUpdateManager.start();

Update Mode

There are two modes

  • Flexible(UpdateManagerConstant.FLEXIBLE) (default) - User can use the app during update download, installation and restart needs to be triggered by user

  • Immediate(UpdateManagerConstant.IMMEDIATE) - User will be blocked until download and installation is finished, restart is triggered automatically

Additionally you can get the Available Version Code of the update and the Number of days passed since the user was notified of an update through the Google Play. You can find these codes in the demo app

mUpdateManager.addUpdateInfoListener(new UpdateInfoListener() {
    @Override
    public void onReceiveVersionCode(final int code) {
        // You can get the available version code of the apk in Google Play
        // Do something here
    }

    @Override
    public void onReceiveStalenessDays(final int days) {
        // Number of days passed since the user was notified of an update through the Google Play
        // If the user hasn't notified this will return -1 as days
        // You can decide the type of update you want to call
    }
});

Monitoring the flexible update download progres

You can monitor the download progress of a Flexible Update using this callback. Note: This is only available for Flexible update mode. You can find more from the official doc

// Callback from Flexible Update Progress
mUpdateManager.addFlexibleUpdateDownloadListener(new FlexibleUpdateDownloadListener() {
    @Override
    public void onDownloadProgress(final long bytesDownloaded, final long totalBytes) {
       // Show a progress bar or anything you want
    }
});

πŸŽ₯ Demo

Flexible Update Immediate Update

❗ Troubleshoot

  • In-app updates works only with devices running Android 5.0 (API level 21) or higher
  • In-app updates are available only to user accounts that own the app. So, make sure the account you’re using has downloaded your app from Google Play at least once before using the account to test in-app updates.
  • Make sure that the app that you are testing in-app updates with has the same application ID and is signed with the same signing key as the one available from Google Play.
  • Because Google Play can only update an app to a higher version code, make sure the app you are testing as a lower version code than the update version code.

You can find more information at Frequently Asked Questions

πŸ‘ Contributions

Any contributions are welcome!

πŸ“„ License

MIT License

Copyright (c) 2019 Sanoj Punchihewa

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

inappupdater's People

Contributors

sanojpunchihewa avatar dependabot-preview[bot] avatar anjanasenanayake avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.