Back to project page LCFR-Mobile-Android.
The source code is released under:
Apache License
If you think the Android project LCFR-Mobile-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 org.dizon.lcfrmobile; //from w w w . jav a 2 s . co m import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import org.dizon.LCFRCAD.CADData; import com.google.gson.*; import android.os.AsyncTask; public class HttpTeste extends AsyncTask<String, Integer, String> { @Override protected String doInBackground(String... urls) { int count = urls.length; if(count!=1) { //bad stuff happens } long epoch=System.currentTimeMillis(); urls[0]+=String.valueOf(epoch); HttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet(urls[0]); HttpResponse response = null; try { response = client.execute(request); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); return null; } // Get the response BufferedReader rd = null; try { rd = new BufferedReader (new InputStreamReader(response.getEntity().getContent())); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } StringBuilder sb = new StringBuilder(); String line = ""; try { while ((line = rd.readLine()) != null) { sb.append(line); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } String cadstring = sb.toString(); Gson gson = new Gson(); CADData cad = gson.fromJson(cadstring, CADData.class); return null; } }