后台更新APP(两句代码实现)

github地址:https://github.com/wenwenwen888/BackgroundUpdate

先看预览图 :

(1)调用Dialog更新对话框效果

《后台更新APP(两句代码实现)》 Dialog.png

(2)调用Notification更新效果

《后台更新APP(两句代码实现)》 Notification.png

前言

1,使用了retorfit2 + rxjava做的下载库

2,apk下载完毕会自动跳到安装界面,下载过程可取消

3,需要修改更多内容可以下载library自行修改

4,不妥之处或BUG请Issues指出,谢谢

Usage

With Gradle:

  compile 'com.wenwenwen888:bgupdate:1.0.7'

How to use

第一句 , 调用下载:

  • (a.调用Dialog对话框下载
  BgUpdate.updateForDialog(context, url, filePath);
  • (b.调用Notification下载
  BgUpdate.updateForNotification(context , url, filePath);
  • (c.url即为下载apk的链接,下面为filepath示例
  String filePath = Environment.getExternalStorageDirectory() + "/xxx.apk";

第二句 , 在onDestroy()的时候关闭服务:

 BgUpdate.closeService(context);

End (。・`ω´・)

    原文作者:温温温888
    原文地址: https://www.jianshu.com/p/29d72d44f99c
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞