Skip to content

Latest commit

 

History

History
162 lines (126 loc) · 9.53 KB

README-EN.md

File metadata and controls

162 lines (126 loc) · 9.53 KB

Table of Contents

  • Rendering
  • Function introduction
  • Demo download experience
  • DownloadManager
  • UpdateConfiguration
  • Steps for usage
  • Skills
  • Version update record
  • End

Rendering

     

Function introduction

  • Support AndroidX
  • Support for custom download process
  • Support Device >= Android M Dynamic Access Request
  • Support notification progress display (or custom display progress)
  • Support Android N
  • Support Android O
  • Support Android P
  • Support Android Q
  • Support Chinese/English
  • Support for custom built-in dialog styles
  • Support for canceling the download (if the notification bar message is sent, it will be removed)
  • Support download completion Delete old APK file after opening new version
  • Download using HttpURLConnection, no other third-party framework is integrated

DownloadManager:Configuration Doc

Initial useDownloadManager.getInstance(this)

Attributes Description Default Value Must be set
context Context null true
apkUrl Apk download Url null true
apkName Apk download name null true
downloadPath apk download path(2.7.0 or higher is deprecated) getExternalCacheDir() false
showNewerToast Whether to prompt the user
"currently the latest version" toast
false false
smallIcon Notification icon (resource id) -1 true
configuration Additional configuration of this library null false
apkVersionCode new apk versionCode
(If set, the version will be judged in the library,
The following properties also need to be set)
Integer.MIN_VALUE false
apkVersionName new apk versionName null false
apkDescription Update description null false
apkSize New version of the apk size (unit M) null false
apkMD5 Md5 (32 bit) of the new apk null false

UpdateConfiguration:Configuration Doc

Attributes Description Default Value
notifyId notification id 1011
notificationChannel Adapt to Android O notifications See the source for details
httpManager Set up your own download process null
enableLog Whether need to log output true
onDownloadListener Callback of the download process null
jumpInstallPage Whether the download completes automatically
pops up the installation page
true
showNotification Whether to display the progress of the
notification bar (background download toast)
true
forcedUpgrade Whether to force an upgrade false
showBgdToast Whether need to “Downloading new version in the background…” true
usePlatform Whether to use AppUpdate website true
onButtonClickListener Button click event listener null
dialogImage Dialog background image resource
(picture specification reference demo)
-1
dialogButtonColor The color of the dialog button -1
dialogButtonTextColor The text color of the dialog button -1
dialogProgressBarColor Dialog progress bar and text color -1

Steps for usage

Step1:

  • root/build.gradle
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
  • app/build.gradle
implementation 'com.github.azhon:AppUpdate:3.0.6'

Step2:Create DownloadManager,For more usage, please see sample code here

UpdateConfiguration configuration = new UpdateConfiguration()

DownloadManager manager = DownloadManager.getInstance(this);
manager.setApkName("appupdate.apk")
        .setApkUrl("https://raw.githubusercontent.com/azhon/AppUpdate/main/apk/appupdate.apk")
        .setSmallIcon(R.mipmap.ic_launcher)
        //Optional parameters
        .setConfiguration(configuration)
        //If this parameter is set, it will automatically determine whether to show tip dialog
        .setApkVersionCode(2)
        .setApkDescription("description...")
        .download();

Step3:ProGuard Rules

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Service

Skills

  • Internal support Chinese / English (other languages only need to take the same name in the corresponding string.xml
  • To view the Log, you only need to filter the Tag at the beginning of AppUpdate
  • Download completed Delete old APK file after opening new version
//Old version apk file save path
boolean b = ApkUtil.deleteOldApk(this, getExternalCacheDir().getPath() + "/appupdate.apk");
  • Tips: The contents of the upgrade dialog can be swiped up and down!
  • If you need to implement your own set of download process, you only need to extends BaseHttpDownloadManager and update the progress with listener.
public class MyDownload extends BaseHttpDownloadManager {}

Version update record

  • v3.0.6 (2021/12/15)

    • [Fix] Android 10 or higher sending notification message bug

End

  • If you encounter problems during use, please feel free to ask Issues.
  • If you have any good suggestions, you can also mention Issues or send email to: [email protected].