Back to project page RestLib.
The source code is released under:
MIT License
If you think the Android project RestLib 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 github.crazymumu.restlib.sample; /*from w ww.j a v a 2s. c o m*/ import github.crazymumu.restlib.RestRequest; import github.crazymumu.restlib.RestResponse; import github.crazymumu.restlib.RestResult; import github.crazymumu.restlib.RestResultReceiver; import github.crazymumu.restlib.RestService; import github.crazymumu.restlib.http.RequestMethod; import android.os.Bundle; import android.app.Activity; import android.view.View; import android.widget.TextView; public class MainActivity extends Activity implements RestResult { private RestResultReceiver restResultReceiver; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); restResultReceiver = new RestResultReceiver(); restResultReceiver.setReceiver(this); } public void run(View view) { RestRequest request = new RestRequest(); request.setMethod(RequestMethod.Get); request.setResource("http://news.gc.ca/web/rss-eng.do?mthd=ntnl"); // Add the key-value pair parameters when necessary. // request.setHeader("key", "value"); // request.setParam("key", "value"); RestService.request(this, request, restResultReceiver); } @Override public void onReceiveRestResult(RestResponse response) { TextView result = (TextView) findViewById(R.id.result); result.setText(response.getResult()); } }