Back to project page android-rest-client.
The source code is released under:
Apache License
If you think the Android project android-rest-client 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 com.dg.examples.restclientdemo; //w ww .j a v a 2 s. c o m import android.app.Activity; import android.os.Bundle; import android.widget.TextView; import android.widget.Toast; import com.dg.examples.restclientdemo.communication.requests.BlogsGoogleRequest; import com.dg.examples.restclientdemo.communication.requests.PatchRequest; import com.dg.examples.restclientdemo.domain.ResponseModel; import com.dg.libs.rest.callbacks.HttpCallback; import com.dg.libs.rest.domain.ResponseStatus; public class MainActivity extends Activity { private TextView textViewResponse; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); textViewResponse = (TextView) findViewById(R.id.textViewResponse); new BlogsGoogleRequest("Official Google Blogs").setCallback(new GoogleBlogsCallback()) .executeAsync(); new PatchRequest("Hello").setCallback(new HttpCallback<Void>() { @Override public void onSuccess(Void responseData, ResponseStatus responseStatus) { Toast.makeText(getApplicationContext(), "Success patch", Toast.LENGTH_LONG).show(); } @Override public void onHttpError(ResponseStatus responseStatus) { Toast.makeText(getApplicationContext(), "FAIL patch", Toast.LENGTH_LONG).show(); } }).executeAsync(); } private final class GoogleBlogsCallback implements HttpCallback<ResponseModel> { @Override public void onSuccess(ResponseModel responseData, ResponseStatus status) { textViewResponse.setText(responseData.toString()); } @Override public void onHttpError(ResponseStatus responseCode) { Toast.makeText(getApplicationContext(), responseCode.getStatusCode() + " " + responseCode.getStatusMessage(), Toast.LENGTH_LONG).show(); } } }