• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Help Error while downloading rss feed in an android app.......

Hello..... I have an Error while developing a Android App in Eclipse Indigo that is while downloading a rss feed in the app . When I start it on the AVDs or in the Physical devices It stopes...
Please Help me out
I am giving the following files:-
1) MainActivity.java
2) activity_main.xml
3) AndroidManifest

Java:
package com.example.topdownloaderlist;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;



import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends Activity {

    TextView tt;


    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tt = (TextView) findViewById(R.id.textView1);
        new DownloadData().execute("http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topfreeapplications/limit=10/xml");
       
    }

    @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;
    }
   
   
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

   
    protected class DownloadData extends AsyncTask<String , Void ,String>{
       

        String myXMLData;
        protected String doInBackground (String... urls){
        try {
        myXMLData = downloadXML(urls[0]);
           
        }
        catch (IOException e){
            return "Sorry, Unable to download the XML file!!";
        }
        return "";
    }

        protected void onPostExecute (String result){
            tt.setText(myXMLData);
            Log.d("AppDetails!!", myXMLData);

           
        }
        public String downloadXML(String theURL) throws IOException {
            int BUFFER_SIZE = 2000;
            InputStream is = null;
            String xmlContent = "";
           
            try{
                URL url = new URL (theURL);
                HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                conn.setReadTimeout(10000);
                conn.setConnectTimeout(25000);
                conn.setRequestMethod("GET");
                conn.setDoInput(true);

                is = conn.getInputStream();
                InputStreamReader isr = new InputStreamReader (is);
                int read;
                char[] readchar = new char [BUFFER_SIZE];
                try{
                    while ((read = isr.read(readchar)) > 0){
                        String data = String.copyValueOf(readchar, 0, read);
                        xmlContent += data;
                        readchar = new char [BUFFER_SIZE];
                }
                    return xmlContent;
                }
                catch (IOException e){
                    e.printStackTrace();
                    return null;
                }
            }
            finally {
                if (is != null){
                    is.close();
                }
            }

            }
        }
   

   
    }


-------------------------------------------------------activity_main.xml file---------------------------------------
Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.topdownloaderlist.MainActivity" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_marginLeft="23dp"
        android:text="TextView" />

</RelativeLayout>

----------------------------------------------------Android-Menifest.xml file---------------------------------------------
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.topdownloaderlist"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="16"
        android:targetSdkVersion="22" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
<uses-permission android:name="android.permission_INTERNET"/>
</manifest>
 
Back
Top Bottom