123456789101112131415161718192021222324252627282930313233343536373839 |
- package com.emato.ich.update;
- import android.content.Context;
- import com.emato.ich.utils.Log;
- import androidx.annotation.NonNull;
- import com.xuexiang.xupdate.aria.AriaDownloadServiceProxyImpl;
- import com.xuexiang.xupdate.easy.config.IUpdateConfigProvider;
- import com.xuexiang.xupdate.easy.config.UpdateConfig;
- import com.xuexiang.xupdate.utils.UpdateUtils;
- import org.jetbrains.annotations.NotNull;
- /**
- * 自定义的XUpdate配置提供者
- */
- public class CustomUpdateConfigProvider implements IUpdateConfigProvider {
- private static final String TAG = CustomUpdateConfigProvider.class.getName();
- @NonNull
- @NotNull
- @Override
- public UpdateConfig getUpdateConfig(@NonNull @NotNull Context context) {
- return UpdateConfig.create()
- .setIsDebug(true) // 开启debug日志
- .setIsWifiOnly(false) // 设置非wifi更新
- .setIsGet(false) // 设置post方式获取下载参数
- .setIsAutoMode(true) // 设置自动更新
- .setParam("versionCode", UpdateUtils.getVersionCode(context)) // 设置默认公共请求参数
- .setParam("appKey", context.getPackageName())
- .setOnInstallListener(new PackageManagerCompat()) // 自定义的下载器
- .setOnUpdateFailureListener(error -> {
- Log.i(TAG, "onCreate: =====================>自动更新失败! " + error.getCode() + ", " + error.getDetailMsg());
- })
- .setIsSupportSilentInstall(true); // 设置是否支持静默安装,默认是true
- }
- }
|