をService使用してダウンロード タスクを管理する がありますHttpURLConnection。
HTTP リクエストを実行する前にカスタムisNetworkAvailableメソッドを使用していますが、リクエスト中に失われた接続をどのように管理するのか疑問に思っています。
ループ内isNetworkAvailableでメソッドを呼び出す必要がありますか (つまり、多くの呼び出しを意味します)。whileで失われた接続を管理する標準的な方法は何HttpURLConnectionですか?
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
FileOutputStream outputStream = openFileOutput(filename, MODE_PRIVATE | MODE_APPEND);
BufferedInputStream in = new BufferedInputStream(connection.getInputStream());
byte[] data = new byte[1024];
int x = 0;
while ((x = in.read(data, 0, 1024)) >= 0) {
outputStream.write(data, 0, x);
}