我想知道一些下载的进度.
当我从互联网上获取一些资源时,像这样:
String myFeed = request.getURI().toString();
URL url = new URL(myFeed);
URLConnection connection = url.openConnection();
HttpURLConnection httpConnection = (HttpURLConnection) connection;
int responseCode = httpConnection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
InputStream in = httpConnection.getInputStream();
// Process the input stream
}
Run Code Online (Sandbox Code Playgroud)
当"InputStream in = httpConnection.getInputStream();"时 被调用,
文件的所有内容立即下载.
如果我使用:
htttpResponse = httpClient.execute(httpRequestBase);
Run Code Online (Sandbox Code Playgroud)
问题是一样的.
如何检测下载的实际进度?
谢谢你们!