## CheckVersionLib[![](https://jitpack.io/v/AlexLiuSheng/CheckVersionLib.svg)](https://jitpack.io/#AlexLiuSheng/CheckVersionLib)
## V2 Version has been born with shocking, strong functions,chain programing, easy to integrate,strong extension
[中文文档](https://github.com/AlexLiuSheng/CheckVersionLib/blob/master/README_UN.MD)
The strongest feature is easier to integrate than version of V1.+
### Effect
<img src="https://github.com/AlexLiuSheng/CheckVersionLib/blob/master/gif/v2.jpg" width=200/><img src="https://github.com/AlexLiuSheng/CheckVersionLib/blob/master/gif/V2.gif" width=200/>
### Features
- [x] Invoke everywhere you want
- [x] **Easy**
- [x] **Strong Extension**
- [x] Adapt to all applications that have update function
- [x] **Customize Ui**
- [x] Support Force Update(one line code)
- [x] Support Silence Download (one line code)
- [x] Adapt to Android Q
### include
```
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```
#### appcompat
```
implementation 'com.github.AlexLiuSheng:CheckVersionLib:2.4.1_appcompat'
```
#### jitpack && android x
```
dependencies {
implementation 'com.github.AlexLiuSheng:CheckVersionLib:2.4.1_androidx'
}
```
### usage
> Only using download mode
the easiest way to use
```
AllenVersionChecker
.getInstance()
.downloadOnly(
UIData.create().setDownloadUrl(downloadUrl)
)
.executeMission(context);
```
`UIData`:UIData is the type of Bundle,it saves some data for displaying ui page,it can use in your customization page/
> Request Version + Download mode
the easiest way to call
```
AllenVersionChecker
.getInstance()
.requestVersion()
.setRequestUrl(requestUrl)
.request(new RequestVersionListener() {
@Nullable
@Override
public UIData onRequestVersionSuccess(String result) {
//get the data response from server,parse,get the `downloadUlr` and some other ui date
...
//return null if you dont want to update application
return UIData.create().setDownloadUrl(downloadUrl);
}
@Override
public void onRequestVersionFailure(String message) {
}
})
.executeMission(context);
```
Some other http params for request app version,as follows
```
AllenVersionChecker
.getInstance()
.requestVersion()
.setHttpHeaders(httpHeader)
.setRequestMethod(HttpRequestMethod.POSTJSON)
.setRequestParams(httpParam)
.setRequestUrl(requestUrl)
.request(new RequestVersionListener() {
@Nullable
@Override
public UIData onRequestVersionSuccess(String result) {
//get the data response from server,parse,get the `downloadUlr` and some other ui date
...
UIData uiData = UIData
.create()
.setDownloadUrl(downloadUrl)
.setTitle(updateTitle)
.setContent(updateContent);
//return null if you dont want to update application
uiData.getVersionBundle().putString("key", "your value");
return uiData;
}
@Override
public void onRequestVersionFailure(String message) {
}
})
.executeMission(context);
```
the instructions above is the basic using for integrating(library has a set of default ui page),you can use some other params,if it does not fit your requirement the above.
### cancel all mission
to avoid memory leak,It is necessary to cancel all missiones when you dont want to use library.you should put code of cancel in properly place.
```
AllenVersionChecker.getInstance().cancelAllMission();
```
### some other functions
first of all,the builder of follow is called `DownloadBuilder`
```
DownloadBuilder builder=AllenVersionChecker
.getInstance()
.downloadOnly();
or
DownloadBuilder builder=AllenVersionChecker
.getInstance()
.requestVersion()
.request()
```
> cancel mission
```
AllenVersionChecker.getInstance().cancelAllMission(this);
```
> silent download
```
builder.setSilentDownload(true); false for default
```
> set the newest version code of your server returned,it is used to verify if use file cache.
- Cache category:first check running app's versionCode whether equal with the installation package.Then check developer whether pass the newest VersionCode ,if so, check the
VersionCode is greater than local,if it is truth ,download apk from server, otherwise use cache.
```
builder.setNewestVersionCode(int); null for default
```
> Force Update
set the listener represent need force update function,it will be call when user cancel the download operation,developer need close all the activities of application.
```
builder.setForceUpdateListener(() -> {
forceUpdate();
});
```
**update in v2.2.1**
for setForceUpdateListener dynamically after server response,you can setForceUpdateListener in callback of http request,eg.
```
public UIData onRequestVersionSuccess(DownloadBuilder downloadBuilder,String result) {
downloadBuilder.setForceUpdateListener(() -> {
forceUpdate();
});
Toast.makeText(V2Activity.this, "request successful", Toast.LENGTH_SHORT).show();
return crateUIData();
}
```
> Force ReDownload no matter there is cache
```
builder.setForceRedownload(true); false for default
```
> set whether show downloading dialog
```
builder.setShowDownloadingDialog(false); true for default
```
> set whether show notification
```
builder.setShowNotification(false); true for default
```
> **run as foreground service(update in 2.2.2)**
recomended
```
builder.setRunOnForegroundService(true); 默认true
```
> customize notification
```
builder.setNotificationBuilder(
NotificationBuilder.create()
.setRingtone(true)
.setIcon(R.mipmap.dialog4)
.setTicker("custom_ticker")
.setContentTitle("custom title")
.setContentText(getString(R.string.custom_content_text))
);
```
> set whether show download failed dialog
```
builder.setShowDownloadFailDialog(false); true for default
```
> customize download apk path
```
builder.setDownloadAPKPath(address); default:/storage/emulated/0/AllenVersionPath/
```
> customize download apk name
```
builder.setApkName(apkName); default:getPackageName()
```
> set download listener
```
builder.setApkDownloadListener(new APKDownloadListener() {
@Override
public void onDownloading(int progress) {
}
@Override
public void onDownloadSuccess(File file) {
}
@Override
public void onDownloadFail() {
}
});
```
> cancel listener
```
builder.setOnCancelListener(() -> {
Toast.makeText(V2Activity.this,"Cancel Hanlde",Toast.LENG
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
android app 升级示例,使用代码 (1627个子文件)
+7hnEet5ItGDVLIi+6ElF8atbdY= 63KB
+7hnEet5ItGDVLIi+6ElF8atbdY= 63KB
+aQ4T9yBJ7Bg3Oe8cDMyj2OPHrU= 118KB
+aQ4T9yBJ7Bg3Oe8cDMyj2OPHrU= 118KB
+m2tULK+NkveAN9papgtrVfWzj8= 34KB
+m2tULK+NkveAN9papgtrVfWzj8= 34KB
+pX8wWGJUY4ilmnsqL5_yecnU44= 13KB
+pX8wWGJUY4ilmnsqL5_yecnU44= 13KB
0nBFGN3fE+dskAeF78Ki5OgwHeg= 59KB
0nBFGN3fE+dskAeF78Ki5OgwHeg= 59KB
0o1JyyN3IfFIu227BXeY8tJPQ4M= 31KB
0o1JyyN3IfFIu227BXeY8tJPQ4M= 31KB
1E0BmWGWvv13dovyh+yzFxNGpwk= 6KB
1E0BmWGWvv13dovyh+yzFxNGpwk= 6KB
3cRtQ5fXk_pCtpXX+vFiT_aqV80= 61KB
3cRtQ5fXk_pCtpXX+vFiT_aqV80= 61KB
4Xa_m8d5xVO91w4iJOVbWwmEGPY= 109KB
4Xa_m8d5xVO91w4iJOVbWwmEGPY= 109KB
6Cq2kHcIRk4TzwTg2SZRwLuhf4U= 660KB
6Cq2kHcIRk4TzwTg2SZRwLuhf4U= 660KB
6dg+pC3l73IrkcWdlzMz9HQ2eX8= 8KB
6dg+pC3l73IrkcWdlzMz9HQ2eX8= 8KB
84YQRRudY1AvDtLEzbDQuq8CGhU= 54KB
84YQRRudY1AvDtLEzbDQuq8CGhU= 54KB
_suPGvqhDBR9mOSErwqOXAHri2c= 18KB
_suPGvqhDBR9mOSErwqOXAHri2c= 18KB
resources-debug.ap_ 1.43MB
sample-debug.apk 3.81MB
1_1.apk 2.61MB
lookups.tab.values.at 22KB
java-sources-proto-map.tab.values.at 14KB
source-to-output.tab.values.at 10KB
proto.tab.values.at 7KB
internal-name-to-source.tab.values.at 7KB
source-to-classes.tab.values.at 5KB
class-fq-name-to-source.tab.values.at 4KB
id-to-file.tab.values.at 1KB
subtypes.tab.values.at 713B
supertypes.tab.values.at 632B
constants.tab.values.at 141B
file-to-id.tab.values.at 103B
azB9clAyhJjDjzEshWVPPzCaHc8= 10KB
azB9clAyhJjDjzEshWVPPzCaHc8= 10KB
gradlew.bat 2KB
gradlew.bat 2KB
executionHistory.bin 1.95MB
classAnalysis.bin 1.02MB
fileHashes.bin 142KB
outputFiles.bin 85KB
jarAnalysis.bin 55KB
taskHistory.bin 28KB
resourceHashesCache.bin 20KB
last-build.bin 81B
build-history.bin 31B
a8d81b9f02a2c3e455fe75cd607923d9.bin 10B
last-build.bin 1B
R$styleable.class 39KB
R$styleable.class 28KB
R$style.class 22KB
R$style.class 21KB
R$attr.class 14KB
DownloadBuilder.class 12KB
R$attr.class 12KB
VersionDialogActivity.class 11KB
R$styleable.class 11KB
V2Activity.class 11KB
NotificationHelper.class 10KB
VersionService.class 10KB
UIActivity.class 10KB
VersionParams.class 9KB
R$id.class 9KB
AllenHttp.class 9KB
DownloadingActivity.class 8KB
AVersionService.class 8KB
DownloadManager.class 8KB
UpdateActivity.class 7KB
R$dimen.class 7KB
R$dimen.class 7KB
CustomVersionDialogActivity.class 7KB
R$drawable.class 6KB
DownloadFailedActivity.class 6KB
R$id.class 6KB
R$drawable.class 6KB
DownloadManager$1.class 6KB
VersionParams$Builder.class 6KB
AllenBaseActivity.class 6KB
R$color.class 5KB
NotificationHelper$showDownloadCompleteNotifcation$1.class 5KB
V1Activity.class 5KB
R$color.class 5KB
RequestVersionManager$1.class 4KB
R$styleable.class 4KB
BuilderManager.class 4KB
VersionService$startDownloadApk$1.class 4KB
R$string.class 4KB
NotificationHelper$updateNotification$1.class 4KB
DownloadingActivity$updateProgress$1.class 4KB
DownloadingActivity$showDefaultDialog$$inlined$apply$lambda$1.class 4KB
FileCallBack.class 4KB
VersionService$init$1.class 4KB
共 1627 条
- 1
- 2
- 3
- 4
- 5
- 6
- 17
qingshui1234567
- 粉丝: 4
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0