Open qrh672114236 opened 6 years ago
OkGo.get(updateBean!!.updatePath) .tag(this) .execute(object :FileCallback(){ override fun onSuccess(response: Response?) { val it = Intent() it.action = Intent.ACTION_VIEW it.setDataAndType(Uri.fromFile(response!!.body().absoluteFile), "application/vnd.android.package-archive") it.flags = Intent.FLAG_ACTIVITY_NEW_TASK startActivity(it) }
override fun downloadProgress(progress: Progress?) { super.downloadProgress(progress) update.isEnabled = false update.text = "更新" + (progress!!.fraction * 100).toInt() + "%" wvprogress.setCurrent((progress.fraction.toDouble() * 100.0 * 0.4).toInt(), "") Log.d("progress==",progress.toString()+"fraction=="+progress.fraction) } })
从下载到成功只回调了一次 downloadProgress 没法看下载进度
看这个:https://github.com/jeasonlzy/okhttp-OkGo/issues/388
OkGo.get(updateBean!!.updatePath)
.tag(this)
.execute(object :FileCallback(){
override fun onSuccess(response: Response?) {
val it = Intent()
it.action = Intent.ACTION_VIEW
it.setDataAndType(Uri.fromFile(response!!.body().absoluteFile), "application/vnd.android.package-archive")
it.flags = Intent.FLAG_ACTIVITY_NEW_TASK
startActivity(it)
}
从下载到成功只回调了一次 downloadProgress 没法看下载进度