android版本如何更新代码,AppUpdate: Android 版本更新 a library for android version update...

本文介绍了一款用于Android应用版本更新的插件,包括Kotlin集成、自定义接口、进度显示、后台下载、强制更新等功能,以及详细的更新日志和使用示例。

Android 版本更新

目录

功能介绍

实现android版本更新

对kotlin适配,调用更简单

自定义接口协议,可以不改变现有项目的协议就能使用

支持get,post请求

支持进度显示,对话框进度条,和通知栏进度条展示

支持后台下载

支持强制更新

支持简单主题色配置(可以自动从顶部图片提取主色)

支持自定义对话框(可以监听下载进度)

支持静默下载(可以设置wifi状态下)

支持android7.0

效果图与示例 apk

09b6d87258fcfbdfc3c4045600882080.png

2e706c7f98d4724dccabfbcf69de7a84.png

dd4cc1fc2686fea14e8b455a7b9ce95f.png

a0079e86fe0c180a01a8136477695ea4.png

c38b61f4783145de524d180af35e43e4.png

Gradle 依赖

java方式引用

dependencies {

compile 'com.qianwen:update-app:3.5.2'

}

download.svgAPI-14%2B-orange.svg?style=flatLicense-Apache%202.0-blue.svgAppUpdate.svg?style=plastic&label=Star

kotlin方式引用

dependencies {

compile 'com.qianwen:update-app-kotlin:1.2.3'

}

download.svgAPI-14%2B-orange.svg?style=flatLicense-Apache%202.0-blue.svgAppUpdate.svg?style=plastic&label=Star

简单使用

1,java方式

new UpdateAppManager

.Builder()

//当前Activity

.setActivity(this)

//更新地址

.setUpdateUrl(mUpdateUrl)

//实现httpManager接口的对象

.setHttpManager(new UpdateAppHttpUtil())

.build()

.update();

2,kotlin方式

updateApp(mUpdateUrl, UpdateAppHttpUtil()).update()

详细说明

更新日志

kotlin版本是依赖java版本的,所以java版本的问题kotlin自然修复

v3.5.2

1,修复下载过程中,关闭对话框不能自动安装问题。

v3.5.1

1,修复bug

v3.5.0

1,优化强制更新

v3.4.8

1,修复bug

v3.4.7

1,优化 APP 安装的问题

v3.4.6

1,优化 APP 安装的问题

v3.4.5

1,增加全局异常捕获方法

.handleException(new ExceptionHandler() {

@Override

public void onException(Exception e) {

}

})

v3.4.4

1,修复bug

v3.4.3

1,修复bug

v3.4.2

1,修复bug

v3.4.1

1,给插件使用者更多的配置和开启一些钩子方便适配不同的业务需求

2,适配android8.0

感谢Jiiiiiin对项目的维护

v3.4.0

1,修复

v3.3.9

1,适配android8.0的通知和安装未知来源的app

感谢typ0520对项目的维护

v3.3.8

1,增加存储空间权限申请

V3.3.7

1,修改默认安装包下载路径为download/packageName

感谢bean-liu对项目的维护

V3.3.6

1,去掉对下载路径前缀的校验。

V3.3.5

1,修复升级对话框布局中的问题。

2,修复静默下载,关闭更新弹窗 再点击更新 一直显示的问题。

V3.3.4

1,修复对话框更新内容过多,升级按钮被挤压的问题。

2,去掉自动从图片提取颜色的功能, 通过.setThemeColor()设置按钮和精度条颜色,

3,兼容compileSdkVersion <25

V3.3.3

1,修复下载路径是重定向路径不能下载的问题

V3.3.2

1,修复正在下载时,返回桌面报错的问题

V3.3.1

1,修复对话框外可以点击的问题

V3.3.0

1,可以设置不显示通知栏进度条。

2,可以设置忽略版本。

3,优化下载时页面卡的问题(由于下载进度回调调用频繁,造成ui线程阻塞)。

4,可以静默下载,类似网易云音乐,并且设置wifi状态下。

V3.2.9

1,新增自定义对话框。

2,适配kotlin,写法更简单。

License

Copyright 2017 千匍

Licensed under the Apache License, Version 2.0 (the "License");

you may not use this file except in compliance with the License.

You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software

distributed under the License is distributed on an "AS IS" BASIS,

WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and

limitations under the License.

plugins { id 'com.android.application' } android { namespace 'com.example.kucun2' compileSdk 33 defaultConfig { applicationId "com.example.kucun2" minSdk 24 targetSdk 33 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_17 targetCompatibility JavaVersion.VERSION_17 } buildFeatures { viewBinding true } } dependencies { implementation "androidx.activity:activity:1.7.2" implementation "androidx.activity:activity-ktx:1.7.2" implementation 'com.google.code.gson:gson:2.8.9' implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'com.google.android.material:material:1.11.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.3' implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.1' implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1' implementation 'androidx.navigation:navigation-fragment:2.4.1' implementation 'androidx.navigation:navigation-ui:2.4.1' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' // 网络请求 implementation 'com.squareup.retrofit2:retrofit:2.9.0' implementation 'com.squareup.retrofit2:converter-gson:2.9.0' // 表格控件 implementation 'io.github.cymchad:BaseRecyclerViewAdapterHelper:4.0.3' // implementation 'io.github.cymchad:BaseRecyclerViewAdapterHelper:4.1.7' implementation 'androidx.recyclerview:recyclerview:1.3.2' // 刷新控件 implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' // Material Design implementation 'com.google.android.material:material:1.11.0' // 对话框 implementation 'com.github.gabriel-TheCode:AestheticDialogs:1.3.6' implementation 'at.favre.lib:bcrypt:0.9.0' // Android专用BCrypt库 implementation 'androidx.room:room-runtime:2.4.3' annotationProcessor 'androidx.room:room-compiler:2.4.3' } 2 issues were found when checking AAR metadata: 1. Dependency 'androidx.activity:activity-ktx:1.8.0' requires libraries and applications that depend on it to compile against version 34 or later of the Android APIs. :app is currently compiled against android-33. Also, the maximum recommended compile SDK version for Android Gradle plugin 7.4.2 is 33. Recommended action: Update this project's version of the Android Gradle plugin to one that supports 34, then update this project to use compileSdkVerion of at least 34. Note that updating a library or application's compileSdkVersion (which allows newer APIs to be used) can be done separately from updating targetSdkVersion (which opts the app in to new runtime behavior) and minSdkVersion (which determines which devices the app can be installed on). 2. Dependency 'androidx.activity:activity:1.8.0' requires libraries and applications that depend on it to compile against version 34 or later of the Android APIs. :app is currently compiled against android-33. Also, the maximum recommended compile SDK version for Android Gradle plugin 7.4.2 is 33. Recommended action: Update this project's version of the Android Gradle plugin to one that supports 34, then update this project to use compileSdkVerion of at least 34. Note that updating a library or application's compileSdkVersion (which allows newer APIs to be used) can be done separately from updating targetSdkVersion (which opts the app in to new runtime behavior) and minSdkVersion (which determines which devices the app can be installed on).
06-05
框架内部支持中/英文(其他语言只需要在对应的string.xml中取相同的名字即可)内部对话框背景图片、按钮支持自定义了查看版本中的Log只需要过滤AppUpdate开头的Tag重点: 如果没有设置downloadPath则默认为getExternalCacheDir()目录,同时不会申请[存储]权限!目录编译问题效果图功能介绍DownloadManagerUpdateConfiguration使用步骤Demo下载体验版本更新记录结语编译问题因为适配了Android O的通知栏,所以依赖的v7包版本比较高appcompat-v7:26.1.0使用的gradle版本为gradle-4.1-all,所以建议使用Android Studio 3.0及以上的版本打开此项目效果图     功能介绍 支持断点下载 支持后台下载 支持自定义下载过程 支持 设备 >= Android M 动态权限的申请 支持通知栏进度条展示(或者自定义显示进度) 支持Android N 支持Android O 支持中/英文双语 支持自定内置对话框的样式 使用HttpURLConnection下载,未集成其他第三方框架更加详细的文档参阅此处《AppUpdate API文档》DownloadManager:配置文档初始化使用DownloadManager.getInstance(this)属性描述默认值是否必须设置context上下文nulltrueapkUrlapk的下载地址nulltrueapkNameapk下载好的名字nulltruedownloadPathapk下载的位置getExternalCacheDir()falseshowNewerToast是否提示用户 "当前已是最新版本"falsefalsesmallIcon通知栏的图标(资源id)-1trueconfiguration这个库的额外配置nullfalseapkVersionCode更新apk的versionCode (如果设置了那么库中将会进行版本判断下面的属性也就需要设置了)1falseapkVersionName更新apk的versionNamenullfalseapkDescription更新描述nullfalseapkSize新版本的安装包大小(单位M)nullfalseauthorities兼容Android N uri授权应用包名falseUpdateConfiguration:配置文档属性描述默认值notifyId通知栏消息id1011notificationChannel适配Android O的渠道通知详情查阅源码httpManager设置自己的下载过程nullbreakpointDownload是否需要支持断点下载trueenableLog是否需要日志输出trueonDownloadListener下载过程的回调nulljumpInstallPage下载完成是否自动弹出安装页面trueshowNotification是否显示通知栏进度(后台下载提示)trueforcedUpgrade是否强制升级falseonButtonClickListener按钮点击事件回调nulldialogImage对话框背景图片资源(图片规范参考demo)-1dialogButtonColor对话框按钮的颜色-1dialogButtonTextColor对话框按钮的文字颜色-1所有版本:点击查看使用步骤第一步: app/build.gradle进行依赖implementation 'com.azhon:appupdate:1.7.3'第二步:创建DownloadManager,更多用法请查看这里示例代码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();第三步:兼容Android N 及以上版本,在你应用的Manifest.xml添加如下代码<--! android:authorities="${applicationId}"  这个值必须与DownloadManager中的authorities一致(不设置则为应用包名)--> <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>第四步:资源文件res/xml/file_paths_public.xml内容<?xml version="1.0" encoding="utf-8"?> <paths>     <external-path         name="app_update_external"         path="/" />     <external-cache-path         name="app_update_cache"         path="/" /> </paths>兼容Android O及以上版本,需要设置NotificationChannel(通知渠道);库中已经写好可以前往查阅NotificationUtil.java温馨提示:升级对话框中的内容是可以上下滑动的哦!如果需要实现自己一套下载过程,只需要继承BaseHttpDownloadManager 并使用listener更新进度public class MyDownload extends BaseHttpDownloadManager {}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值