Android Open Source - LCFR-Mobile-Android Http Teste






From Project

Back to project page LCFR-Mobile-Android.

License

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.

Java Source Code

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;
  }

}




Java Source Code List

org.dizon.LCFRCAD.CADData.java
org.dizon.LCFRCAD.Calls.java
org.dizon.LCFRCAD.Pcalls.java
org.dizon.lcfr.ProtocolContent.java
org.dizon.lcfr.ProtocolFile.java
org.dizon.lcfr.ProtocolXmlParser.java
org.dizon.lcfr.Protocol.java
org.dizon.lcfrmobile.GetS3File.java
org.dizon.lcfrmobile.HttpTeste.java
org.dizon.lcfrmobile.IncidentDetailActivity.java
org.dizon.lcfrmobile.IncidentDetailFragment.java
org.dizon.lcfrmobile.IncidentListActivity.java
org.dizon.lcfrmobile.IncidentListFragment.java
org.dizon.lcfrmobile.MainActivity.java
org.dizon.lcfrmobile.MainDisplayFragment.java
org.dizon.lcfrmobile.OnDownloadNotify.java
org.dizon.lcfrmobile.ProtocolDetailActivity.java
org.dizon.lcfrmobile.ProtocolDetailFragment.java
org.dizon.lcfrmobile.ProtocolListActivity.java
org.dizon.lcfrmobile.ProtocolListFragment.java
org.dizon.lcfrmobile.S3IndexChecker.java
org.dizon.lcfrmobile.SettingsActivity.java
org.dizon.lcfrmobile.dummy.DummyContent.java