Giter VIP home page Giter VIP logo

app-updater's Introduction

Android App Updater

Demo Image

Check Version Download APK Install Dwonload Error

Test Pass

Real Machine

Device Adroid API Type
Nokia 7+ 28 Real
Samsung Galaxy S8 28 Real
Samsung Galaxy S9+ 26 Real
Xperia XZ1 Compact 26 Real
Huawei Mate 9 24 Real
LG G6 24 Real
Xiaomi Mix2 26 Real
ASUS Zenfone 5 20 Real

Virtual Machine

Device Adroid API Type
Pixel 2 26 Virtual
Pixel 2 28 Virtual
Nexus 4 22 Virtual
Nexus 5 19 Virtual
Nexus 5X 25 Virtual
Nexus 6 24 Virtual
Nexus 6P 27 Virtual
Nexus 7 (2012) 22 Virtual
Nexus 9 25 Virtual
Nexus 10 22 Virtual

Setup

(1) Gradle (This lib use dataBinding, Plz add dataBinding enabled = true)

android {
    ...
    repositories {
        maven { url 'https://jitpack.io' }
    }
    dataBinding {
        enabled = true
    }
    ...
}
dependencies {
    implementation 'com.github.HsunTsai:app-updater:1.0.2'
}

(2) AndroidManiferst.xml

Add permission

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

Add uses-library & provider in your

<uses-library
      android:name="org.apache.http.legacy"
      android:required="false" />
<provider
        android:name="com.hsun.appupdater.FileProvider"
        android:authorities="${applicationId}.fileProvider"
        android:grantUriPermissions="true"
        android:exported="false">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/update_apk_paths" />
</provider>

(3) Your backend server

You need a backend server(API) to tell the version number that the application wants to upgrade.

The JSON format like =>

{
    "version": "1.0.1",
    "versionCode": "2",
    "apkUrl": "https://www.hsunserver.ga/download/appUpdater_2_1.0.1.apk",
    "updateInformation": "●Your information 1\n●Your information 2\n●Your information 3",
    "releaseTime": 1551059568060,
    "appSize": 12806567,
    "constraint": true
}

(4) Usage

public void checkVersion(){
    AppUpdaterDialogSettings appUpdaterDialogSettings = new AppUpdaterDialogSettings();
    appUpdaterDialogSettings
        .setUpdateInfoTextResource(R.string.update_info_text) // auto replact ${version} to your new version
        .setDownloadBtnTextResource(R.string.hint_open_browser) // default value => 'open browser to download APK'
        .setUpdateBtnTextResource(R.string.common_update) // default value => 'Update'
        .setDialogThemeColor("#0087DC"); // default value => '#4DB6AC'

    new AppUpdater(MainActivity.this)
        .setVersion(BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE)
        .setUpdateParam("https://www.hsunserver.ga/download/updateData.json")
        //.setUpdateParam("https://www.hsunserver.ga/download/updateData.json", AppUpdater.RequestMethod.GET)
        //.setUpdateParam("https://www.hsunserver.ga/download/updateData.json", AppUpdater.RequestMethod.POST, data)
        //.setLogShow(true)
        .setDialogSettings(appUpdaterDialogSettings)
        .run();
}

Pattern

Created by MVVM pattern

Dependencies

Volley

app-updater's People

Contributors

hsuntsai avatar

Stargazers

 avatar Joe Zhu avatar

Watchers

 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.