I use okhttp library for download files in android. I download successfully. But something is wrong when I pause and resume download.
Response request = new Req
val call = client.newCall(request)
call.enqueue(object : Callback {
override fun onFailure(call: Call, e: IOException) {
listener.onFail(e)
}
override fun onResponse(call: Call, response: Response) {
// write the stream to a file (downloading happening)
val stream = response.body?.byteStream()
}
})
// this will stop the downloading
call.cancel()
to resume use the "Range" header with your request and append the stream to already downloaded file.