Android Open Source - AndroidNative---HTTP-Call Main Activity

From Project

Back to project page AndroidNative---HTTP-Call.


The source code is released under:

MIT License

If you think the Android project AndroidNative---HTTP-Call 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 com.mobmaxime.httprequest;
/*from  w w w  .ja v a 2 s  .c o  m*/
import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.widget.ListView;

public class MainActivity extends Activity {

  String url = null;
  private ListView listView;

  final Context context = this;
  List<createRow> rowItems;
  LazyAdapter adapter;

  protected void onCreate(Bundle savedInstanceState) {
    Log.d("URL", "Hmm");
    rowItems = new ArrayList<createRow>();

    listView = (ListView) findViewById(;

    url = "";

    Thread thread = new Thread(new Runnable() {

      public void run() {
        // TODO Auto-generated method stub
        String data = commonDialog.httpCall(url,

        JSONObject jsonData = commonDialog.xml2json(data);
        JSONObject rss;
        JSONObject channel;
        JSONArray items = null;
        try {
          rss = jsonData.getJSONObject("rss");
          channel = rss.getJSONObject("channel");
          items = channel.getJSONArray("item");
        } catch (JSONException e) {
          // TODO Auto-generated catch block

        Log.d("Lengh", items.length() + "");

        for (int i = 0; i < items.length(); i++) {
          try {
            JSONObject content = items.getJSONObject(i);

            String title = content.getString("title");
            Log.d("Title", title);
            rowItems.add(new createRow(title));
          } catch (JSONException e) {
            // TODO Auto-generated catch block

        runOnUiThread(new Runnable() {
          public void run() {

            // stuff that updates ui
            adapter = new LazyAdapter(getApplicationContext(),



    // commonDialog.httpCall(url);


Java Source Code List