1、When apkVersionCode()
is set the latest VersionCode, it will automatically judge whether to display the dialog, download and install
- Adapt to Android 13 notification permission, and when set
showNotification(true)
, clicking the upgrade button will request notification permission, and the download will continue regardless of whether you agree or not - When set
forcedUpgrade(true)
,display dialog has progress bar
2、When apkVersionCode()
is not set, it can be regarded as a downloader, which will only download and install
3、Since Android Q version restricts background apps from launching Activity, a notification will be sent to the notification bar when the download is complete (ignoring the showNotification value, you need to allow notifications to be sent)
- Rendering
- Function introduction
- Demo download experience
- Steps for usage
- Skills
- Version update record
- End
- Support Java、Kotlin
- Support AndroidX
- Support for custom download process
- Support Android 4.1 and above
- Support notification progress display, adapt to Android 13
- Support Chinese/Traditional/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
implementation 'io.github.azhon:appupdate:4.3.6'
Since in-app updates are prohibited by GooglePlay policy, it can be handled in productFlavors
- GooglePlay policy
- Library provides a version without no operationClick see more
android {
//...
productFlavors {
other {}
googlePlay {}
}
}
dependencies {
otherImplementation 'io.github.azhon:appupdate:latest-version'
googlePlayImplementation 'io.github.azhon:appupdate-no-op:latest-version'
}
Kotlin
val manager = DownloadManager.Builder(this).run {
apkUrl("your apk url")
apkName("appupdate.apk")
smallIcon(R.mipmap.ic_launcher)
//If this parameter is set, it will automatically determine whether to show dialog
apkVersionCode(2)
apkVersionName('v4.2.2')
apkSize("7.7MB")
apkDescription("description...")
//Optional parameters...
build()
}
manager?.download()
Java
DownloadManager manager = new DownloadManager.Builder(this)
.apkUrl("your apk url")
.apkName("appupdate.apk")
.smallIcon(R.mipmap.ic_launcher)
//If this parameter is set, it will automatically determine whether to show dialog
.apkVersionCode(2)
.apkVersionName("v4.2.2")
.apkSize("7.7MB")
.apkDescription("description...")
//Optional parameters...
.build();
manager.download();
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Service
- Internationalization support, 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
val result = ApkUtil.deleteOldApk(this, "${externalCacheDir?.path}/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
.
class MyDownload : BaseHttpDownloadManager() {}
-
v4.3.6(2024/10/22)
- [Opt] Change DownloadManager release() to public
- 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].