Back to project page SandB-Android.
The source code is released under:
GNU General Public License
If you think the Android project SandB-Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package edu.grinnell.sandb.xmlpull; /* w w w . j a v a 2s. c om*/ import java.io.IOException; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.util.Date; import android.os.AsyncTask; import android.util.Log; public class XmlCheckAgeTask extends AsyncTask<String, Integer, Long> { public static final String TAG = "XmlCheckAgeTask"; public static interface CheckAgeListener { public void receive(Long result); } private final CheckAgeListener mListener; public XmlCheckAgeTask(CheckAgeListener l) { super(); this.mListener = l; } @Override protected Long doInBackground(String... args) { return lastModified(args[0]); } @Override protected void onPostExecute(Long result) { mListener.receive(result); } // GET THE LAST MODIFIED TIME public static long lastModified(String url) { HttpURLConnection.setFollowRedirects(false); HttpURLConnection con; long date = 0; try { con = (HttpURLConnection) new URL(url).openConnection(); date = con.getLastModified(); if (date == 0) Log.i(TAG, "No last-modified information."); else Log.i(TAG, "Last-Modified: " + new Date(date)); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return date; } }