Android Open Source - spring-for-android-starter-book Main Activity

From Project

Back to project page spring-for-android-starter-book.


The source code is released under:

Apache License

If you think the Android project spring-for-android-starter-book 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

// w  w  w . j  a v  a2  s .c o m

import org.springframework.http.converter.xml.SimpleXmlHttpMessageConverter;
import org.springframework.web.client.RestTemplate;

import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Menu;
import android.widget.TextView;

public class MainActivity extends Activity {

  public void onCreate(Bundle savedInstanceState) {
    final TextView resultTextView = (TextView) findViewById(;

    AsyncTask<String, Void, IfConfigMeXml> simpleGetTask =  new AsyncTask<String, Void, IfConfigMeXml>() {
      protected IfConfigMeXml doInBackground(String... params) {
        RestTemplate restTemplate = new RestTemplate();
        SimpleXmlHttpMessageConverter mappingSimpleXmlHttpMessageConverter = new SimpleXmlHttpMessageConverter();
        return restTemplate.getForObject(params[0], IfConfigMeXml.class);
      protected void onPostExecute(IfConfigMeXml result) {
        String resultAsString =  new StringBuilder().append("Your current IP is : ")
        resultTextView.setText(resultAsString );
    String url = "";
    // triggers the task; it will update the resultTextView once it is done

Java Source Code List