Android Open Source - groundify-android Web Service Response






From Project

Back to project page groundify-android.

License

The source code is released under:

GNU General Public License

If you think the Android project groundify-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 deftsoft.android.iground.utility;
//from   ww  w  .  jav  a2 s  .  c  o m
import java.io.IOException;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;

import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;

public class WebServiceResponse extends AsyncTask<Void, Void, String> {

  public interface onWebResponse {

    public void onSuccess(String result);

    public void onError(String error);
  }

  private onWebResponse listener;

  private boolean isresult = false;

  private final String PLEASE_WAIT = "Please wait...";

  private String url;

  private ProgressDialog mProgressDialog;

  public WebServiceResponse(Context context, String url,

  onWebResponse callback) {
    // TODO Auto-generated constructor stub
    this.url = url;

    mProgressDialog = new ProgressDialog(context);

    mProgressDialog.setMessage(PLEASE_WAIT);

    mProgressDialog.setCanceledOnTouchOutside(false);

    listener = callback;

    execute();
  }

  @Override
  protected void onPreExecute() {
    // TODO Auto-generated method stub
    super.onPreExecute();

    mProgressDialog.show();
  }

  @Override
  protected String doInBackground(Void... params) {
    // TODO Auto-generated method stub
    String result = null;

    try {
      DefaultHttpClient httpClient = new DefaultHttpClient();

      HttpGet httpget = new HttpGet(url);

      HttpResponse httpResponse = httpClient.execute(httpget);

      HttpEntity httpEntity = httpResponse.getEntity();

      result = EntityUtils.toString(httpEntity);

      isresult = true;
    } catch (ClientProtocolException e) {
      // TODO Auto-generated catch block
      result = "ClientProtocolException";
      isresult = false;
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block

      result = "IOException";
      isresult = false;
      e.printStackTrace();
    }

    return result;
  }

  @Override
  protected void onPostExecute(String result) {
    // TODO Auto-generated method stub
    super.onPostExecute(result);
    if (mProgressDialog != null && mProgressDialog.isShowing()) {
      mProgressDialog.dismiss();
    }

    if (isresult) {
      listener.onSuccess(result);
    } else {

      listener.onError(result);
    }
  }
}




Java Source Code List

.ConsequenceImageGridActivity.java
custom.adapter.pckg.GridAdapter.java
custom.adapter.pckg.MyAdapter.java
custom.adapter.pckg.MyLazyAdapter.java
custom.adapter.pckg.MySpinnerAdapter.java
deftsoft.android.iground.utility.Base64.java
deftsoft.android.iground.utility.ChildDetail.java
deftsoft.android.iground.utility.DatePickerFragment.java
deftsoft.android.iground.utility.DeleteChildWebResponse.java
deftsoft.android.iground.utility.GetNewCosequence.java
deftsoft.android.iground.utility.HttpUploader.java
deftsoft.android.iground.utility.ImageFilePath.java
deftsoft.android.iground.utility.SetConSeqWebServiceWebResponse.java
deftsoft.android.iground.utility.SignupDetail.java
deftsoft.android.iground.utility.TimePickerFragment.java
deftsoft.android.iground.utility.Utility.java
deftsoft.android.iground.utility.ViewConseqDetail.java
deftsoft.android.iground.utility.WebServiceLinks.java
deftsoft.android.iground.utility.WebServiceResponse.java
deftsoft.android.image.upload.Base64.java
deftsoft.android.image.upload.UploadImageToServer.java
deftsoft.iground.android.AddChildScreen.java
deftsoft.iground.android.AddConsequenceActivity.java
deftsoft.iground.android.BridgeClass.java
deftsoft.iground.android.CopyOfConsequenceImageGridActivity.java
deftsoft.iground.android.DeleteChildScreen.java
deftsoft.iground.android.GrounChild.java
deftsoft.iground.android.HomeScreenActivity.java
deftsoft.iground.android.Home.java
deftsoft.iground.android.LogInScreenActivity.java
deftsoft.iground.android.MyHttpClient.java
deftsoft.iground.android.SignUpScreenActivity.java
deftsoft.iground.android.ThankYouActivity.java
deftsoft.iground.android.UILApplication.java
deftsoft.iground.android.ViewConsequence.java
deftsoft.iground.android.CustomizeListView.AbsListViewBaseActivity.java
deftsoft.iground.android.CustomizeListView.BaseActivity.java
deftsoft.iground.android.CustomizeListView.Constants.java
iground.child.interfaces.Consequnceselected.java