AppUpdater - 一個從Google Play, GitHub, Amazon 或者 F-Droid上檢查app更新的library
一個從Google Play, GitHub, Amazon 或者 F-Droid上檢查app更新的library。
使用說明:
Sample Project
你可以在Google Play上現在最新的 sample APK:
如何引入
把這個 repository添加到你的projectbuild.gradle中:
repositories {
maven {
url "https://jitpack.io"
}
} 把library添加到你的module build.gradle中:
dependencies {
compile 'com.github.javiersantos:AppUpdater:1.1'
} 使用
在Manifest中添加INTERNET和ACCESS_NETWORK_STATE權限:
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Activity
AppUpdater appUpdater = new AppUpdater(this); appUpdater.start();
Fragment
AppUpdater appUpdater = new AppUpdater(getActivity()); appUpdater.start();
自定義
Use the builder and add following:
// (Optional) Provide a Display mode. // Default: Display.DIALOG .setDisplay(Display.DIALOG) .setDisplay(Display.SNACKBAR) .setDisplay(Display.NOTIFICATION)
// (Optional) Provide a duration for the Snackbars. // Default: Duration.NORMAL .setDuration(Duration.NORMAL) .setDuration(Duration.INDEFINITE)
// (Optional) Provide a source for the updates. // Default: UpdateFrom.GOOGLE_PLAY .setUpdateFrom(UpdateFrom.GOOGLE_PLAY) .setUpdateFrom(UpdateFrom.GITHUB) .setUpdateFrom(UpdateFrom.AMAZON) .setUpdateFrom(UpdateFrom.FDROID)
// (Required for GITHUB, optional otherwise) Provide the GitHub user and repo where releases are available.
.setGitHubUserAndRepo("javiersantos", "AppUpdater")// (Optional) Updates will be displayed only every X times the app ascertains that a new update is available. // Default: 1 (Always) .showEvery(5)
// (Optional) Show dialog, snackbar or notification although there aren't updates. // Default: false .showAppUpdated(true)
其它特性
獲得最新的更新并和當前安裝版本比較(異步)
AppUpdaterUtils appUpdaterUtils = new AppUpdaterUtils(this)
//.setUpdateFrom(UpdateFrom.AMAZON)
//.setUpdateFrom(UpdateFrom.FDROID)
//.setUpdateFrom(UpdateFrom.GITHUB)
//.setGitHubUserAndRepo("javiersantos", "AppUpdater")
.withListener(new AppUpdaterUtils.AppUpdaterListener() {
@Override
public void onSuccess(String latestVersion, Boolean isUpdateAvailable) {
Log.d("AppUpdater", latestVersion + ", " + Boolean.toString(isUpdateAvailable));
});
appUpdaterUtils.start(); 
本文由用戶 基窩弍少 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!
