Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6042905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:50:30+00:00 2026-05-23T06:50:30+00:00

So, I’ve built an Ok RSS reader for a new sports app I’ll be

  • 0

So, I’ve built an Ok RSS reader for a new sports app I’ll be releasing soon. It will read feeds from various sports sites and display them. The problem I have is that the feeds are loading immediately on the start of an activity which requires an internet connection.

If an internet connection goes down or there is latency, the app will sometimes hang and/or force close on me. I need something pause the screen until the feed contents have been pulled from the various XML feeds.

Many news apps and other RSS readers do this when you click on a new news category. You’ll get an animated “updating” or “loading” dialogue. Here is my current code.

public class MyActivity extends ListActivity implements OnClickListener {

    Button btn1;
    Button btn2;
    Button btn3;
    Button btn4;

    WebView webview;

    TextView feedTitle;
    TextView feedDescribtion;
    TextView feedPubdate;
    TextView feedLink;

private RSSFeed myRssFeed = null;

public class MyCustomAdapter extends ArrayAdapter<RSSItem> {

 public MyCustomAdapter(Context context, int textViewResourceId,
   List<RSSItem> list) {
  super(context, textViewResourceId, list);
 }

 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
  // TODO Auto-generated method stub
  //return super.getView(position, convertView, parent);

  View row = convertView;

  if(row==null){
   LayoutInflater inflater=getLayoutInflater();
   row=inflater.inflate(R.layout.row, parent, false);
  }

  TextView listTitle=(TextView)row.findViewById(R.id.listtitle);
  listTitle.setText(myRssFeed.getList().get(position).getTitle());
  TextView listTitle2=(TextView)row.findViewById(R.id.listtitle2);
  listTitle2.setText(myRssFeed.getTitle());
  TextView listPubdate=(TextView)row.findViewById(R.id.listpubdate);
  String str = (myRssFeed.getList().get(position).getPubdate());


  SimpleDateFormat inputFormatter = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z"); //please notice the    capital M
  SimpleDateFormat outputFormatter = new SimpleDateFormat("MM/dd/yyyy");

  try {
      Date date = inputFormatter.parse(str);
      String text = outputFormatter.format(date);
      listPubdate.setText(text);
  } catch (ParseException e ) {
      e.printStackTrace();
  }


  return row;
 }
}

  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.hawkcentral);

      btn1 = (Button) findViewById(R.id.hawknation_button);
      btn1.setOnClickListener(this);

      btn2 = (Button) findViewById(R.id.hawkcentral_button);
      btn2 .setOnClickListener(this);

      btn3 = (Button) findViewById(R.id.hawkeyesports_button);
      btn3 .setOnClickListener(this);

      espn = (Button) findViewById(R.id.espn_button);

      feedTitle = (TextView)findViewById(R.id.feedtitle);
      feedDescribtion = (TextView)findViewById(R.id.feeddescribtion);
      feedPubdate = (TextView)findViewById(R.id.feedpubDate);
      feedLink = (TextView)findViewById(R.id.feedlink);

           readRss();
       }

       private void readRss(){

      feedTitle.setText("--- wait ---");
      feedDescribtion.setText("");
      feedPubdate.setText("");
      feedLink.setText("");
      setListAdapter(null);

      Toast.makeText(this, "Reading RSS, Please wait.", Toast.LENGTH_LONG).show();


       try {
          URL rssUrl = new URL("http://www.sports.com/feed");
          SAXParserFactory mySAXParserFactory = SAXParserFactory.newInstance();
          SAXParser mySAXParser = mySAXParserFactory.newSAXParser();
          XMLReader myXMLReader = mySAXParser.getXMLReader();
          RSSHandler myRSSHandler = new RSSHandler();
          myXMLReader.setContentHandler(myRSSHandler);
          InputSource myInputSource = new InputSource(rssUrl.openStream());
          myXMLReader.parse(myInputSource);

          myRssFeed = myRSSHandler.getFeed();

         } catch (MalformedURLException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
         } catch (ParserConfigurationException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
         } catch (SAXException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
         } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
         }

         if (myRssFeed!=null)
         {
          TextView feedTitle = (TextView)findViewById(R.id.feedtitle);
          TextView feedDescribtion = (TextView)findViewById(R.id.feeddescribtion);
          TextView feedPubdate = (TextView)findViewById(R.id.feedpubDate);
          TextView feedLink = (TextView)findViewById(R.id.feedlink);
          feedTitle.setText(myRssFeed.getTitle());
          feedDescribtion.setText(myRssFeed.getDescription());
          feedPubdate.setText(myRssFeed.getPubdate());
          feedLink.setText(myRssFeed.getLink());

          MyCustomAdapter adapter =
           new MyCustomAdapter(this, R.layout.row, myRssFeed.getList());
          setListAdapter(adapter);
         }
         }       


@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
 // TODO Auto-generated method stub
 Intent intent = new Intent(this,HawkCentralDetails.class);
 Bundle bundle = new Bundle();
 bundle.putString("keyTitle", myRssFeed.getItem(position).getTitle());
 bundle.putString("keyDescription", myRssFeed.getItem(position).getDescription());
 bundle.putString("keyLink", myRssFeed.getItem(position).getLink());
 bundle.putString("keyPubdate", myRssFeed.getItem(position).getPubdate());
 intent.putExtras(bundle);
      startActivity(intent);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T06:50:31+00:00Added an answer on May 23, 2026 at 6:50 am

    You should try using the AsyncTask it will help follow the below link

    http://developer.android.com/reference/android/os/AsyncTask.html

    With AsyncTask you get to load the data in background and is displayed when loaded till the time you can display a ProgressDialog

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
We're building an app, our first using Rails 3, and we're having to build
I have a bunch of posts stored in text files formatted in yaml/textile (from
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.