4 Star 0 Fork 0

Gitee 极速下载 / apk-update-tool

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/MengLeiGitHub/ApkUpdateTool
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

ApkUpdateTool

##ApkUpdateTool

android 應用版本更新框架,將所有的版本更新業務進行了進一步的封裝,開發人員衹需簡單的接入就可以進行版本更新了 ,支持自定義的dialog提示和自定義 notification

##使用方法

如何接入?

gradle 接入方式

   compile 'com.ml.apkupadte:appupdate:1.0.8@aar'
   compile 'com.ml.asynchttp:asynchttp-android:1.1.1'

####調用

首先在清單文件中加入服務,以及網絡權限和文件讀寫權限

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    
    
    <service android:name="com.uyin.apkupdate.service.UpdateVersionService"/>

####在线检测 (直接设置更新接口,以及参数)

    ApkUpdateOnline<User> userApkUpdateOnline= new ApkUpdateOnline<User>(Activity.this, "http://120.26.106.106:8080/rest/common/user/login.do") {
                   @Override
                   public String getTitle(User user) {
                   
                       return user.getData().getUsername();
                   }

                   @Override
                   public String getContent(User user) {
                   //dialog显示content内容
                       return user.getData().getUsername();
                   }

                   @Override
                   public String getDownURL(User user) {
                   
                       return user.getData().getAvatar();
                   }

                   @Override
                   public boolean isMustUpdate(User user) {
                   //是否必须更新,如果为true 关闭dialog app则会关闭
                       return false;
                   }

                   @Override
                   public boolean isShowDialog(User t1) {
                   //是否显示dialog
                       return true;
                   }

                   @Override
                   public String getResultDesConstants(String str) {
                   //这个是对于网络数据加密的,如果数据没加密无需操作该方法
                       return null;
                   }
               };
               HashMap   map=new HashMap<>();
               map.put("username","15093201628");
               map.put("password","e565f08d058ebb4a1c99907a9860a93b");

               userApkUpdateOnline.CheckByJSONPost(map);

####本地检测 ,需要传入一个实体类

    ApkUpdateCheck apkUpdateCheck=new ApkUpdateCheck(new AppVersionCheckCallBack<User>(){

                   @Override
                   public String getTitle(User user) {
                       return null;
                   }

                   @Override
                   public String getContent(User user) {
                       return null;
                   }

                   @Override
                   public String getDownURL(User user) {
                       return user.getMsg();
                   }

                   @Override
                   public boolean isMustUpdate(User user) {
                       return false;
                   }

                   @Override
                   public boolean isShowDialog(User t1) {
                       return false;
                   }

                   @Override
                   public String getResultDesConstants(String str) {
                       return null;
                   }
               });
               User user=new User();
               user.setMsg("下载地址");
               apkUpdateCheck.setActivity(Activity activity)
               apkUpdateCheck.check(user);

#####注意 :實體類型的字段必須要和網絡請求返回的字段一致,否則會出錯

如何自定義dialog和 notification?

如果要自定義dialog,衹需要繼承ApkUpdateDialog

public class DefaultDialog extends ApkUpdateDialog {
    public DefaultDialog(Context context) {
        super(context);
    }

    @Override
    public int getLayout() {
        return R.layout.app_update_custom_dialog;
    }

    @Override
    public int getCancleViewId() {
        return R.id.cancel;
    }

    @Override
    public int getConfirmViewId() {
        return R.id.confirm;
    }

    @Override
    public int getTitleViewId() {
        return R.id.dialog_title;
    }

    @Override
    public int getContentViewId() {
        return R.id.dialog_deatail;
    }
}

*和dialog不用的是,notification不但可以繼承ApkUpdateNotification來實現,你也可以通過實現NoticeListener來自己創建更炫的notification

public    class DefaultNotification extends ApkUpdateNotification {


    public DefaultNotification(Application application) {
        super(application);
    }



    @Override
    protected Notification initNotification(Notification downLoadNotification) {

        return  downLoadNotification;
    }

    @Override
    public int getLayoutId() {
        return R.layout.view_notification_updateversion;
    }

    @Override
    public void updateRoteView(RemoteViews remoteView, long current, long total) {
        int  progress= (int) (current*100f/total);
        remoteView.setTextViewText(R.id.tv_progress,""+progress+"%");
        remoteView.setProgressBar(R.id.pb_progress,100,progress,false);
    }


    @Override
    protected void onFinish() {

    }
}


使用自定義的dialog和 Notification

 ApkUpdateCheck(AppVersionCheckCallBack appVersionCheckCallBack,ApkUpdateDialog apkUpdateDialog,NoticeListener noticeListener)
 
 ApkUpdateOnline(Activity activity,String url, ApkUpdateDialog apkUpdateDialog, NoticeListener noticeListener)
 

##android 代码混淆



-keep class com.async.**
-keepclassmembers class com.async.** { *; }
-keep enum com.async.**
-keepclassmembers enum com.async.** { *; }
-keep interface com.async.**
-keepclassmembers interface com.async.** { *; }

 # Gson
 -keepattributes Signature
 -keepattributes *Annotation*
 -keep class sun.misc.Unsafe { *; }
 -keep class com.google.gson.stream.** { *; }
 # 使用Gson时需要配置Gson的解析对象及变量都不混淆。不然Gson会找不到变量。
 # 将下面替换成自己的实体类
 -keep class com.example.bean.** { *; }	

##有问题反馈 在使用中有任何问题,欢迎反馈给我,可以用以下联系方式跟我交流

##作者其他开源

空文件

简介

暂无描述 展开 收起
AIDL 等 2 种语言
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/mirrors/apk-update-tool.git
git@gitee.com:mirrors/apk-update-tool.git
mirrors
apk-update-tool
apk-update-tool
master

搜索帮助