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

  • Home
  • SEARCH
  • 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 3495774
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:10:04+00:00 2026-05-18T12:10:04+00:00

Solution: Okay,I’ve found the solution from your answers since your answers are not completely

  • 0

Solution:

Okay,I’ve found the solution from your answers since your answers are not completely working

First we need to use Handler to post a Runnable to main/UI thread to run UpdateDisplay() and but define ProgressDialog under UIThread not other threads which was also crucial.

Here is the final code :

public final String RSSFEEDOFCHOICE = "http://www.deals2buy.com/rssgen/tech.xml";

public final String tag = "RSSReader";
private RSSFeed feed = null;
private Handler handler = new Handler();
private ProgressDialog dialog;

/** Called when the activity is first created. */

public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.main);
    dialog = ProgressDialog.show(RSSReader.this, "Loading",
            "Loading, please wait..");
    Thread t = new Thread() {
        public void run() {
            feed = getFeed(RSSFEEDOFCHOICE);
            handler.post(new Runnable() {
                public void run() {
                    dialog.dismiss();
                    UpdateDisplay();
                };
            });
        }
    };

    t.start();
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Problem :

When Android application first load, this is what happens :

  1. Retrieving RSS content from Url and parse it into RSSFeed feed instance variable via getFeed(String url).
  2. Showing these feeds to users in ListView via UpdateDisplay() method.

When these are happening, I wanted to show a ProgressDialog to users to notify them about system are retriving content like “Loading, please wait…” Once getFeed(String Url):RSSFeed is done, ProgressDialog will be dismissed and UpdateDisplay():void will be invoked.

So this is my first attempt :

public final String RSSFEEDOFCHOICE = "somewhere.xml"; //coming from http
public final String tag = "RSSReader";
private RSSFeed feed = null;
/** Called when the activity is first created. */

public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.main);
    ProgressDialog dialog = ProgressDialog.show(RSSReader.this, "Loading...", "Loading, please wait");
    feed = getFeed(RSSFEEDOFCHOICE);
    dialog.dismiss();
    UpdateDisplay();
}

And it doesn’t show the ProgressDialog so it didn’t work the way I want. Since I belived it is because ProgressDialog is continues progress, it should be handled by another Thread.

Here is my second attempt :

public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.main);
    Thread t = new Thread()
    {
        public void run()
        {
            ProgressDialog dialog = ProgressDialog.show(RSSReader.this, "Loading...", "Loading, please wait");
            feed = getFeed(RSSFEEDOFCHOICE);
            dialog.dismiss();
        }   
    };

    UpdateDisplay();
}

It was okay till UpdateDisplay() since this method was handled by main thread and it wasn’t waiting anything so I thought maybe I should have put it under t Thread after dialog.dismiss().

So I did this :

public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.main);
    Thread t = new Thread()
    {
        public void run()
        {
            ProgressDialog dialog = ProgressDialog.show(RSSReader.this, "Loading...", "Loading, please wait");
            feed = getFeed(RSSFEEDOFCHOICE);
            dialog.dismiss();
                    UpdateDisplay();
        }   
    };
}

But then debugger said at run-time : only the main thread which handles onCreate():void can reach and use View objects because it creates them.

Now, I am so messed up and feel like quitting programming.

Some one can help me :/

Thanks in advance.

  • 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-18T12:10:05+00:00Added an answer on May 18, 2026 at 12:10 pm

    Okay,I’ve found the solution from your answers since your answers are not completely working

    First we need to use Handler to post a Runnable to main/UI thread to run UpdateDisplay() and but define ProgressDialog under UIThread not other threads which was also crucial.

    Here is the final code :

    public final String RSSFEEDOFCHOICE = "http://www.deals2buy.com/rssgen/tech.xml";
    public final String tag = "RSSReader";
    private RSSFeed feed = null;
    private Handler handler = new Handler();
    private ProgressDialog dialog;
    
    /** Called when the activity is first created. */
    
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.main);
        dialog = ProgressDialog.show(RSSReader.this, "Loading",
                "Loading, please wait..");
        Thread t = new Thread() {
            public void run() {
                feed = getFeed(RSSFEEDOFCHOICE);
                handler.post(new Runnable() {
                    public void run() {
                        dialog.dismiss();
                        UpdateDisplay();
                    };
                });
            }
        };
    
        t.start();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, I've looked all over the internet for a good solution to get PHP
Solution: I've misinterpreted the example from SQL Books Online. Yes, that below the section
Okay,.. I'm looking into technologies for a 'Case Management' solution design at the moment
I need to remove all whitespace from string, but quotations should stay as they
Solution -- WorkflowProject   -- Workflow1   -- Workflow2 -- WebProject (WAP)   -- App_Data     -- MyDatabase.vdb3
Solution to original problem (below) may have been discovered. I commented out <identity> ...
Solution for writing a program for keep secret photos. I have many secret photos
Programmatic solution of course...
The solution we developed uses a database (sqlserver 2005) for persistence purposes, and thus,
The solution is crying out for the MSMQ solution but unfortunately the posting service

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.