評価用のアプリを作成していますが、最後にダウンロードしてから変更された場合にのみ Web ページをダウンロードする必要があります。最後に変更した日付を Long として保存する必要があるため、メソッド getDate() は long を返します。HttpURLConnection と URLConnection を使用しようとしましたが、解決できませんでした。私の試みの中で、私は使用しようとしました:
If-Modified-Sinceですが、どういうわけか、304 応答コードを受信せず、200 のみを受信しました。コード:
HttpURLConnection huc = null; try { URL url = new URL(pages.get(0).getUrl()); huc = (HttpURLConnection) url.openConnection(); huc.setIfModifiedSince(pages.get(0).getDate()); huc.connect(); Log.d("App", "Since: " + huc.getIfModifiedSince()); Log.d("App", "Response: " + huc.getResponseCode()); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } //output since: 1354320000000 - which is the return of the getDate method. Response: 200
html etagsですが、サーバーが Last-Modified タグに応答しないため、応答から情報を取得できませんでした。
前もって感謝します