android app 更新服务,android app应用内更新

1.表现形式:下载完成后会自动弹出安装界面。已适配7.0.

0818b9ca8b590ca3270a3433284dd417.png

2.github 地址 https://github.com/hunanqi/HNQApkInstall

3.使用方式:

(1)在项目的的gradle文件中加上:

maven { url 'https://jitpack.io' }

0818b9ca8b590ca3270a3433284dd417.png

allprojects {

repositories {

jcenter()

maven { url 'https://jitpack.io' }

}

}

(2)在app的gradle中加上:

compile 'com.github.hunanqi:HNQApkInstall:1.0.0'

(3)在activity中:

Intent intent = new Intent(MainActivity.this, DownApkIntentService.class);

Bundle bundle = new Bundle();

bundle.putString(DownApkConstant.URL, "http://imtt.dd.qq.com/16891/F93BBCA5868A3D335CF3DE847C8B4687.apk?fsname=com.tianxia.hnq.erweima_1.0_1.apk&csr=1bbd");

bundle.putString(DownApkConstant.NAME, "sss.apk");

bundle.putInt(DownApkConstant.IMAGE_ID, R.mipmap.ic_launcher);

bundle.putString(DownApkConstant.TITLE, "应用更新");

intent.putExtras(bundle);

startService(intent);上面需要的参数依次是:apk下载的网络地址,apk下载在本地的名字,通知栏的图标,通知栏的标题。

4.下载后的app 地址:getExternalCacheDir()+"/"+通过ointent传过来的name,如上sss.apk

5.关于原理:

采用intentservice下载,handler发送通知。

6.关于适配:此处采用应用的缓存地址,故不需要读写存储卡权限,亦不需要动态申请权限。

7.0应用内分享,已在moudle中使用FileProvider。服务已在moudle中注册。自己工程只需要集成该moudle库。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值