title: android: display title and text from Wikipedia article
body: <p>I'm working on an app which parses JSON objects from Wikipedia and displays both the 'title' and 'text' attributes. I have looked for similar examples but none work directly with a Wikipedia page.</p>
  
  <p>For example, if I wanted to parse that information from the page:</p>
  
  <pre><code>http://en.wikipedia.org/wiki/Plaza_de_España_(Madrid)
  </code></pre>
  
  <p>I would have to first select a section to work with, like:</p>
  
  <pre><code>http://en.wikipedia.org/w/api.php?format=jsonfm&amp;action=parse&amp;page=Plaza_de_España_(Madrid)
  </code></pre>
  
  <p>and then parse the JSON object, right?. If I wanted to display the title and the text of that specific section, how do I insert the data into two TextViews (one for the title, another for the remaining text)?</p>
  
  <p><em>EDIT</em> 
  I have the following code:</p>
  
  <pre><code>package com.example.jsontest;
  import org.json.JSONException;
  import org.json.JSONObject;
  import android.app.Activity;
  import android.app.ProgressDialog;
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.view.Menu;
  import android.widget.TextView;
  import android.widget.Toast;
  
  public class MainActivity extends Activity {
  private ProgressDialog pDialog;
  
  // wikipedia URL
  private static String url = "http://es.wikipedia.org/w/api.php?page=Plaza_de_España_(Madrid)&amp;action=parse&amp;section=6&amp;format=jsonfm";
  // JSON nose names
  private static final String TAG_TITLE = "title";
  private static final String TAG_TEXT = "text";
  private static String TITLE,DATA;
  TextView titleTextView, dataTextView;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      titleTextView = (TextView)findViewById(R.id.titleTextView);
      dataTextView = (TextView)findViewById(R.id.dataTextView);
      new GetData().execute();
  }
  
  // Async action
  private class GetData extends AsyncTask&lt;Void,Void,Void&gt;{
      @Override
      protected void onPreExecute(){
          super.onPreExecute();
          // show progress dialog
          pDialog = new ProgressDialog(MainActivity.this);
          pDialog.setMessage("Espera, por favor...");
          pDialog.setCancelable(false);
          pDialog.show();
      }
      @Override
      protected Void doInBackground(Void... arg0){
          // create service handler
          ServiceHandler sh = new ServiceHandler();
          // url request
          String jsonStr = sh.makeServiceCall(url, ServiceHandler.GET);
  
          if(jsonStr!=null){
              try{
                  JSONObject jsonObj = new JSONObject(jsonStr);
                  TITLE = jsonObj.getString(TAG_TITLE);
                  Toast.makeText(getBaseContext(), TITLE, Toast.LENGTH_SHORT).show();
                  DATA = jsonObj.getString(TAG_TEXT);
                  titleTextView.setText(TITLE.toString());
                  dataTextView.setText(DATA.toString());
              }catch(JSONException e){
                  e.printStackTrace();
              }
          }else{
              Toast.makeText(getBaseContext(), R.string.error, Toast.LENGTH_SHORT).show();
          }
          return null;
      }
      @Override
      protected void onPostExecute(Void result){
          super.onPostExecute(result);
          // dismiss progress dialog
          if(pDialog.isShowing()){
              pDialog.dismiss();
          }
      }
  }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
  }
  }
  </code></pre>
  
  <p>But it doesn't work as planned...</p>