Android Open Source - Self-Hosted-GPS-Tracker Self Hosted G P S Tracker Request






From Project

Back to project page Self-Hosted-GPS-Tracker.

License

The source code is released under:

GNU General Public License

If you think the Android project Self-Hosted-GPS-Tracker listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package fr.herverenault.selfhostedgpstracker;
//from  w  ww.  ja v a 2 s  .  c  om
import java.net.HttpURLConnection;
import java.net.URL;

import android.os.AsyncTask;
import android.util.Log;

public class SelfHostedGPSTrackerRequest extends AsyncTask<String, Void, Void> {
  private final static String MY_TAG = "SelfHostedGPSTrackerRequest";
  
  protected Void doInBackground(String... urlText) {
    try {
      URL url = new URL(urlText[0]);  
      HttpURLConnection conn = (HttpURLConnection) url.openConnection();
      conn.setReadTimeout(10000 /* milliseconds */);
      conn.setConnectTimeout(15000 /* milliseconds */);
      conn.setRequestMethod("GET");
      conn.setDoInput(true);
      conn.connect();
      int response = conn.getResponseCode();
      Log.d(MY_TAG, "HTTP request done : " + response);
      // that's ok, nothing more to do here
    } catch (Exception e) {
      // we cannot do anything about that : network may be temporarily down
      Log.d(MY_TAG, "HTTP request failed");
    }
    return null;
  }
}




Java Source Code List

fr.herverenault.selfhostedgpstracker.SelfHostedGPSTrackerActivity.java
fr.herverenault.selfhostedgpstracker.SelfHostedGPSTrackerPrefs.java
fr.herverenault.selfhostedgpstracker.SelfHostedGPSTrackerRequest.java
fr.herverenault.selfhostedgpstracker.SelfHostedGPSTrackerService.java