Ich möchte in der Lage sein, eine http-Verbindung zu einer bestimmten Datei in Android zu öffnen und starten Sie den Download. Ich muss auch in der Lage sein, den Download irgendwann zu pausieren und später fortzusetzen. Wie wird das in Android erreicht? Ich möchte den Download nicht noch einmal starten.Pause/Resume http Verbindung Download
7
A
Antwort
1
Eine solche Downloader wurde here posted:
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
if(ISSUE_DOWNLOAD_STATUS.intValue()==ECMConstant.ECM_DOWNLOADING){
File file=new File(DESTINATION_PATH);
if(file.exists()){
downloaded = (int) file.length();
connection.setRequestProperty("Range", "bytes="+(file.length())+"-");
}
}else{
connection.setRequestProperty("Range", "bytes=" + downloaded + "-");
}
connection.setDoInput(true);
connection.setDoOutput(true);
progressBar.setMax(connection.getContentLength());
in = new BufferedInputStream(connection.getInputStream());
fos=(downloaded==0)? new FileOutputStream(DESTINATION_PATH): new FileOutputStream(DESTINATION_PATH,true);
bout = new BufferedOutputStream(fos, 1024);
byte[] data = new byte[1024];
int x = 0;
while ((x = in.read(data, 0, 1024)) >= 0) {
bout.write(data, 0, x);
downloaded += x;
progressBar.setProgress(downloaded);
}
Verwandte Themen
- 1. http Download-Dateiname
- 2. HTTP Download sehr große Datei
- 3. Handle sehr große http Download
- 4. Wie funktioniert der HTTP-Download?
- 5. Vollduplex HTTP-Verbindung
- 6. Android HTTP-Verbindung
- 7. Java http Verbindung
- 8. Öffnen http-Verbindung: android.os.NetworkOnMainThreadException
- 9. iOS Check-Server-Verbindung und erfolgreichen Download
- 10. Force String Download mit http-Header
- 11. Abrufen des Dateinamens von HTTP-Download-Datei
- 12. C++ Winsock Download-Datei abgeschnitten HTTP Header
- 13. Datei mit partiellem Download (HTTP) herunterladen
- 14. Download Excel-Datei über aurelia-http-Client
- 15. Django Pandas HTTP-Antwort (Download-Datei)
- 16. Eine http-Verbindung erneut versuchen
- 17. HTTP-Antwort von der Dropbox-Zip-Download-Anfrage (? Dl = 1)
- 18. Unterschied zwischen der Verwendung von Download-Manager und normalem http-Download
- 19. Fehler mit HTTP-Verbindung: Schließen Header
- 20. RestAssuredMockMvc Verbindung zu http: // localhost: 8080 abgelehnt
- 21. Logstash HTTP-Eingabe-Plugin - Verbindung verweigert
- 22. Schließen akka-http websocket Verbindung vom Server
- 23. Spring Cloud: Feign und HTTP-Verbindung Pooling
- 24. Android http Verbindung mit OkHttp nicht funktionieren
- 25. Kill HTTP (S) Verbindung in Apache
- 26. http persistente Verbindung und SSL-Sitzung
- 27. golang1.4 HTTP-Server Verbindung im Leerlauf halten
- 28. Rmi Server Client remote Verbindung mit dem Download-Code localhost
- 29. Wie wird eine HTTP-Verbindung in einer speziellen Klasse eingerichtet?
- 30. Wildcard auf wget zu http Download letzte Version
Haben Sie diese sehen http://stackoverflow.com/questions/6237079/resume-http-file-download-in-java – laxonline
@laxonline großer Dank ! Wenn du dies als Antwort postest, kann ich es akzeptieren und dieses schließen. –