The library supports Chinese/English (other languages only need to take the same name in the corresponding string.xml)
Focus: If downloadPath is empty, the default is getExternalCacheDir() directory, and the [storage] permission will not be request!
- Rendering
- Function introduction
- DownloadManager
- UpdateConfiguration
- Steps for usage
- Demo download experience
- Version update record
- Conclusion
- Support AndroidX
- Support breakpoint download
- Support background download
- 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 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
More detailed documentation see here《AppUpdate API Doc》
Initial use
DownloadManager.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 | 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) |
1 | false |
| apkVersionName | new apk versionName | null | false |
| apkDescription | Update description | null | false |
| apkSize | New version of the apk size (unit M) | null | false |
| authorities | Support Android N uri license | package Name | false |
| 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 |
| breakpointDownload | Whether need to support breakpoint downloads | true |
| 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 |
| 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 |
All versions:Click to view
implementation 'com.azhon:appupdate:2.1.0'- If you are using
AndroidX, please implementationappupdateX
implementation 'com.azhon:appupdateX:2.1.0'Step2:Create DownloadManager,For more usage, please see sample code here
DownloadManager manager = DownloadManager.getInstance(this);
manager.setApkName("appupdate.apk")
.setApkUrl("https://raw.githubusercontent.com/azhon/AppUpdate/master/apk/appupdate.apk")
.setSmallIcon(R.mipmap.ic_launcher)
//可设置,可不设置
.setConfiguration(configuration)
.download();The authorities value set in the provider must be the same as the authorities set in the DownloadManager (the application package name is not set)
android:authorities="${applicationId}"
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths_public" />
</provider>-
If you implementation the
appupdateXversion<provider android:name="androidx.core.content.FileProvider" android:authorities="${applicationId}" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths_public" /> </provider>
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-path
name="app_update_external"
path="/" />
<external-cache-path
name="app_update_cache"
path="/" />
</paths>Step5:Cancel the download, cancel the download and continue downloading. Please refer to the Step2 of the document
private DownloadManager manager;
//取消下载
manager.cancel();//旧版本apk的文件保存地址
boolean b = ApkUtil.deleteOldApk(this, getExternalCacheDir().getPath() + "/appupdate.apk");
- Compatible with Android O and above, you need to set
NotificationChannel; the library has been written to go to viewNotificationUtil.java - 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
extendsBaseHttpDownloadManagerand update the progress with listener.
public class MyDownload extends BaseHttpDownloadManager {}
Click to download Demo to experience
- v2.1.0
- Added "Downloading new version in the background…" Toast switch
- Added support for AndroidX
- If you encounter problems during use, please feel free to ask Issues.






