{"id":15027361,"url":"https://github.com/alexliusheng/checkversionlib","last_synced_at":"2025-10-25T02:48:25.699Z","repository":{"id":48159992,"uuid":"68989768","full_name":"AlexLiuSheng/CheckVersionLib","owner":"AlexLiuSheng","description":"版本检测升级（更新）库。an auto check version library（app update） on Android","archived":false,"fork":false,"pushed_at":"2023-07-18T20:46:53.000Z","size":21773,"stargazers_count":2710,"open_issues_count":64,"forks_count":488,"subscribers_count":56,"default_branch":"master","last_synced_at":"2025-05-15T05:07:20.755Z","etag":null,"topics":["android","app","appupdate","checkversion","update","updateapp","updateversion","version","versioncheck"],"latest_commit_sha":null,"homepage":"https://github.com/AlexLiuSheng/CheckVersionLib","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlexLiuSheng.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-09-23T04:47:25.000Z","updated_at":"2025-05-15T00:06:13.000Z","dependencies_parsed_at":"2023-10-20T16:35:14.031Z","dependency_job_id":null,"html_url":"https://github.com/AlexLiuSheng/CheckVersionLib","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexLiuSheng%2FCheckVersionLib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexLiuSheng%2FCheckVersionLib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexLiuSheng%2FCheckVersionLib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexLiuSheng%2FCheckVersionLib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlexLiuSheng","download_url":"https://codeload.github.com/AlexLiuSheng/CheckVersionLib/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254276447,"owners_count":22043867,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","app","appupdate","checkversion","update","updateapp","updateversion","version","versioncheck"],"created_at":"2024-09-24T20:06:18.011Z","updated_at":"2025-10-25T02:48:20.663Z","avatar_url":"https://github.com/AlexLiuSheng.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"## CheckVersionLib[![](https://jitpack.io/v/AlexLiuSheng/CheckVersionLib.svg)](https://jitpack.io/#AlexLiuSheng/CheckVersionLib)\n\n## V2 Version has been born with shocking, strong functions,chain programing, easy to integrate,strong extension\n[中文文档](https://github.com/AlexLiuSheng/CheckVersionLib/blob/master/README_UN.MD)\n\nThe strongest feature is easier to integrate than version  of V1.+\n\n### Effect\n \u003cimg src=\"https://github.com/AlexLiuSheng/CheckVersionLib/blob/master/gif/v2.jpg\" width=200/\u003e\u003cimg src=\"https://github.com/AlexLiuSheng/CheckVersionLib/blob/master/gif/V2.gif\" width=200/\u003e\n \n### Features\n- [x] Invoke everywhere you want\n\n- [x] **Easy**\n\n- [x] **Strong Extension**\n\n- [x] Adapt to all applications that have update function\n\n- [x] **Customize Ui**\n\n- [x] Support Force Update（one line code）\n\n- [x] Support Silence Download （one line code）\n\n- [x] Adapt to Android 13\n\n### include\n```\nallprojects {\n\t\trepositories {\n\t\t\t...\n\t\t\tmaven { url 'https://jitpack.io' }\n\t\t}\n\t}\n```\n\n```\n\ndependencies {\n\t        implementation 'com.github.AlexLiuSheng:CheckVersionLib:2.4.2'\n\t}\n```\n\n### usage\n\n\n\n\u003e Only using download mode\n\nthe easiest way to use\n\n```\n        AllenVersionChecker\n                .getInstance()\n                .downloadOnly(\n                        UIData.create().setDownloadUrl(downloadUrl)\n                )\n                .executeMission(context);\n```\n\n`UIData`：UIData is the type of Bundle，it saves some data for displaying ui page，it can use in your customization page/\n\n\n\n\u003e Request Version + Download mode\n\nthe easiest way to call \n```\n   AllenVersionChecker\n                .getInstance()\n                .requestVersion()\n                .setRequestUrl(requestUrl)\n                .request(new RequestVersionListener() {\n                    @Nullable\n                    @Override\n                    public UIData onRequestVersionSuccess(String result) {\n                        //get the data response from server,parse,get the `downloadUlr` and some other ui date\n                      \n                        ...\n                        //return null if you dont want to update application\n                        return UIData.create().setDownloadUrl(downloadUrl);\n                    }\n\n                    @Override\n                    public void onRequestVersionFailure(String message) {\n\n                    }\n                })\n                .executeMission(context);\n\n\n```\nSome other http params for request app version,as follows\n\n```\n AllenVersionChecker\n                .getInstance()\n                .requestVersion()\n                .setHttpHeaders(httpHeader)\n                .setRequestMethod(HttpRequestMethod.POSTJSON)\n                .setRequestParams(httpParam)\n                .setRequestUrl(requestUrl)\n                .request(new RequestVersionListener() {\n                    @Nullable\n                    @Override\n                    public UIData onRequestVersionSuccess(String result) {\n                        //get the data response from server,parse,get the `downloadUlr` and some other ui date\n                        ...\n                        UIData uiData = UIData\n                                .create()\n                                .setDownloadUrl(downloadUrl)\n                                .setTitle(updateTitle)\n                                .setContent(updateContent);\n                        //return null if you dont want to update application\n                        uiData.getVersionBundle().putString(\"key\", \"your value\");\n                        return uiData;\n\n                    }\n\n                    @Override\n                    public void onRequestVersionFailure(String message) {\n\n                    }\n                })\n                .executeMission(context);\n```\n\nthe 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.\n\n### cancel all mission\nto 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.\n```\n AllenVersionChecker.getInstance().cancelAllMission();\n```\n### some other functions\nfirst of all,the builder of follow is called `DownloadBuilder`\n```\n DownloadBuilder builder=AllenVersionChecker\n                .getInstance()\n                .downloadOnly();\n                \n                \n      or          \n                \n                \n                \n DownloadBuilder builder=AllenVersionChecker\n                 .getInstance()\n                 .requestVersion()\n                 .request()\n```\n\u003e cancel mission\n\n ```\n  AllenVersionChecker.getInstance().cancelAllMission(this);\n\n```\n\u003e silent download\n  \n  ```\n   builder.setSilentDownload(true); false for default\n  ```\n\u003e set the newest version code of your server returned，it is used to verify if use file cache.\n \n  - 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 \n   VersionCode is greater than local,if it is truth ,download apk from server, otherwise use cache.\n  ```\n   builder.setNewestVersionCode(int); null for default \n  ```\n\u003e Force Update\n\n  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.\n\n  ```\n  builder.setForceUpdateListener(() -\u003e {\n                forceUpdate();\n            });\n\n```    \n**update in v2.2.1** \n   for setForceUpdateListener dynamically after server response,you can setForceUpdateListener in callback of http request,eg.\n  ```\n     public UIData onRequestVersionSuccess(DownloadBuilder downloadBuilder,String result) {\n                            downloadBuilder.setForceUpdateListener(() -\u003e {\n                                forceUpdate();\n                            });\n                            Toast.makeText(V2Activity.this, \"request successful\", Toast.LENGTH_SHORT).show();\n                            return crateUIData();\n                        }\n  ```  \n\u003e Force ReDownload no matter there is cache\n\n\n  \n```\n builder.setForceRedownload(true); false for default\n``` \n\n\u003e set whether show downloading dialog\n```\nbuilder.setShowDownloadingDialog(false); true for default\n```\n\u003e set whether  show notification\n\n```\nbuilder.setShowNotification(false);  true for default \n```\n\u003e **run as foreground service（update in 2.2.2）**\nrecomended\n```\nbuilder.setRunOnForegroundService(true); 默认true\n```\n\u003e customize notification\n```\n      builder.setNotificationBuilder(\n                 NotificationBuilder.create()\n                         .setRingtone(true)\n                         .setIcon(R.mipmap.dialog4)\n                         .setTicker(\"custom_ticker\")\n                         .setContentTitle(\"custom title\")\n                         .setContentText(getString(R.string.custom_content_text))\n         );\n```\n\u003e set whether show download failed dialog\n\n```\n  builder.setShowDownloadFailDialog(false); true for default\n```\n\u003e customize download apk path\n\n```\n  builder.setDownloadAPKPath(address); default：/storage/emulated/0/AllenVersionPath/\n```\n\u003e customize download apk name\n```\n  builder.setApkName(apkName); default：getPackageName()\n```\n\u003e set download listener\n\n```\n   builder.setApkDownloadListener(new APKDownloadListener() {\n             @Override\n             public void onDownloading(int progress) {\n                 \n             }\n\n             @Override\n             public void onDownloadSuccess(File file) {\n\n             }\n\n             @Override\n             public void onDownloadFail() {\n\n             }\n         });\n```\n\u003e cancel listener\n```\n\n builder.setOnCancelListener(() -\u003e {\n            Toast.makeText(V2Activity.this,\"Cancel Hanlde\",Toast.LENGTH_SHORT).show();\n        });\n```\n**if u want to monitor the cancel operation in different state**\n- ` builder.setDownloadingCancelListener();`\n- `builder.setDownloadFailedCancelListener();`\n- `builder.setReadyDownloadCancelListener();`\n\n\u003e set commit click listener(**added after 2.2.2**)\n\n- ` builder.setReadyDownloadCommitClickListener();`\n- `builder.setDownloadFailedCommitClickListener();`\n\u003e silent download+install directly（dont popup update dialog）\n```\n    builder.setDirectDownload(true);\n           builder.setShowNotification(false);\n           builder.setShowDownloadingDialog(false);\n           builder.setShowDownloadFailDialog(false);\n```\n\u003e customize install callback\n```\n  setCustomDownloadInstallListener(CustomInstallListener customDownloadInstallListener)\n```\n\n### customize the ui page\n\nCustomization page used the way of listener,developer need return the Dialog(parent:android.app) that you customized\n\n\n - all the dialog must initiate with the context inside the listener.\n \n - the data fo page takes from UIData\n\n\u003e **Customize Show Version Dialog**\n\n   set`CustomVersionDialogListener`\n   \n\n- define the page **must** have a commit download button,the id of button must be `@id/versionchecklib_version_dialog_commit`\n\n- if has cancel button(ignore if not),the id of button must be `@id/versionchecklib_version_dialog_cancel`\n\neg.\n\n```\n  builder.setCustomVersionDialogListener((context, versionBundle) -\u003e {\n            BaseDialog baseDialog = new BaseDialog(context, R.style.BaseDialog, R.layout.custom_dialog_one_layout);\n            //versionBundle is instance of UIData，passed from developer,it can be use to display \n            TextView textView = baseDialog.findViewById(R.id.tv_msg);\n            textView.setText(versionBundle.getContent());\n            return baseDialog;\n        });\n\n```\n\n\u003e **customize downloading dialog page**\n\nset`CustomDownloadingDialogListener`\n\n\n- if has cancel button(ignore if not),the id of button must be`@id/versionchecklib_loading_dialog_cancel`\n\n\n```\n    builder.setCustomDownloadingDialogListener(new CustomDownloadingDialogListener() {\n            @Override\n            public Dialog getCustomDownloadingDialog(Context context, int progress, UIData versionBundle) {\n                BaseDialog baseDialog = new BaseDialog(context, R.style.BaseDialog, R.layout.custom_download_layout);\n                return baseDialog;\n            }\n// loop invoke the updateUI method when downloading\n            @Override\n            public void updateUI(Dialog dialog, int progress, UIData versionBundle) {\n                TextView tvProgress = dialog.findViewById(R.id.tv_progress);\n                ProgressBar progressBar = dialog.findViewById(R.id.pb);\n                progressBar.setProgress(progress);\n                tvProgress.setText(getString(R.string.versionchecklib_progress, progress));\n            }\n        });\n```\n\n\u003e **customize download failed page**\n\nsetCustomDownloadFailedListener\n\n- if having button of **retry**,the id must be`@id/versionchecklib_failed_dialog_retry`\n\n- if having the button of **commit/cancel**,the id must be `@id/versionchecklib_failed_dialog_cancel`\n\n```\n   builder.setCustomDownloadFailedListener((context, versionBundle) -\u003e {\n            BaseDialog baseDialog = new BaseDialog(context, R.style.BaseDialog, R.layout.custom_download_failed_dialog);\n            return baseDialog;\n        });\n```\n***\n\n###  ProGuard\n```\n-keepattributes *Annotation*\n-keepclassmembers class * {\n    @org.greenrobot.eventbus.Subscribe \u003cmethods\u003e;\n}\n-keep enum org.greenrobot.eventbus.ThreadMode { *; }\n \n# Only required if you use AsyncExecutor\n-keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {\n    \u003cinit\u003e(java.lang.Throwable);\n}\n -keep class com.allenliu.versionchecklib.**{*;}\n```\n\n### update Log\n  - 2.2.1\n    - fix the bugs of memory leak\n    - use binder to pass params\n    - some known issues \t\n\n### Last\n\n***\n\n - download the  [demo](https://github.com/AlexLiuSheng/CheckVersionLib/blob/master/sample/src/main/java/com/allenliu/sample/v2/V2Activity.java) to view  more functions\n \n - thanks all for the support library\n \n - star/issue is welcome\n \n\n\n### License\n\n***\n\nApache 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexliusheng%2Fcheckversionlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexliusheng%2Fcheckversionlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexliusheng%2Fcheckversionlib/lists"}