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 7777343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:07:06+00:00 2026-06-01T18:07:06+00:00

I have an AsyncTask that much many rss info, and then applying it to

  • 0

I have an AsyncTask that much many rss info, and then applying it to the UI.
I have an indicator for the loading proccess, and while it loads the info in background the UI runs smoothly, but when I call PublishProgress() so I can edit the UI, the indicator freezes.
Here’s a bit of code to explain it better:

                class LoadRss extends AsyncTask<Void, Void, Void> {
                    protected Void doInBackground(Void...voids) {
                        changeRSS(checkedId);
                        publishProgress();
                        return null;
                     }
                    protected void onPostExecute(Void voids) {

                        frameAnimation.stop();
                        syncHomeSymbol.setImageResource(R.drawable.none);
                        syncHomeSymbol.setBackgroundColor(color.background_dark);
                     }
                    @Override
                    protected void onProgressUpdate(Void... values) {
                        super.onProgressUpdate(values);
                        InitHome();
                        }
                }
            new LoadRss().execute();

changeRSS is the method that extracts the rss info.

InitHome is the method that changes the UI.

Thank you very much!

InitHome

private void InitHome() {
if (isNetworkAvailable()) {
    homeLayout.removeAllViews();
    int enclosureCounter = 0;
        for (int i=0;i<rssRes.getLength();i++) {
            String title;
                final String link;
                String description, pubDate;
            EnclosureItem enclosure;
            title = rssRes.getTitle()[i];
            link = rssRes.getLink()[i];
            description = rssRes.getDescription()[i];
            pubDate = rssRes.getPubDate()[i];
            try {
                enclosure = rssRes.getEnclosure().get(enclosureCounter);
            if (enclosure.getPos() == i) {
                LinearLayout horizontal = new LinearLayout(this);
                horizontal.setOrientation(LinearLayout.HORIZONTAL);
                horizontal.setBackgroundResource(R.drawable.rounded_layout);
                LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
                p.setMargins(10, 10, 10, 10);
                horizontal.setLayoutParams(p);
                horizontal.setOnClickListener(new OnClickListener() {

                        public void onClick(View v) {
                        Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(link));
                        startActivity(browserIntent);
                        }
                    });
                ImageView img = new ImageView(this);
                Drawable drawable = LoadImageFromWebOperations(enclosure.getUrl());
                img.setImageDrawable(drawable);
                LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(120, LinearLayout.LayoutParams.FILL_PARENT);
                img.setLayoutParams(layoutParams);
                img.setScaleType(ScaleType.CENTER_CROP);
                horizontal.addView(img);
                LinearLayout vertical = new LinearLayout(this);
                vertical.setOrientation(LinearLayout.VERTICAL);

                TextView textTitle = new TextView(this);
                if (SPM.getFix()) {
                    textTitle.setGravity(Gravity.LEFT);
                }
                else {
                    textTitle.setGravity(Gravity.RIGHT);
                }
                textTitle.setTextSize(1, 18);
                textTitle.setText(Html.fromHtml("<font color='#92b64a'>"+title+"</font><br />"));
                vertical.addView(textTitle);

                TextView textDescription = new TextView(this);
                    if (SPM.getFix()) {
                        textDescription.setGravity(Gravity.LEFT);
                    }
                    else {
                        textDescription.setGravity(Gravity.RIGHT);
                    }
                    String str = Html.fromHtml(description).toString();
                    try{
                        str = str.substring(0,str.lastIndexOf("\n\n"));
                    }
                    catch (IndexOutOfBoundsException e) { }
                    textDescription.setText(Html.fromHtml(new RssOrganizer(str,false).getDescription()));
                vertical.addView(textDescription);

                TextView textpubDate = new TextView(this);
                if (SPM.getFix()) {
                    textpubDate.setGravity(Gravity.LEFT);
                }
                else {
                    textpubDate.setGravity(Gravity.RIGHT);
                }
                textpubDate.setText(new RssOrganizer(pubDate,true).getPubDate()+"\n\n");
                vertical.addView(textpubDate);
                enclosureCounter++;
                horizontal.addView(vertical);
                homeLayout.addView(horizontal);
            }
            else {
                setRegHome(i);
            }
        }
            catch (IndexOutOfBoundsException e) {
                setRegHome(i);
        }
        }
}

else
{
        tRSS.setText(R.string.noINNERinternetConnection);
}   
}

private void setRegHome(int i) {

    String title;
    final String link;
    String description, pubDate;
    title = rssRes.getTitle()[i];
    link = rssRes.getLink()[i];
    description = rssRes.getDescription()[i];
    pubDate = rssRes.getPubDate()[i];
    LinearLayout vertical = new LinearLayout(this);
    vertical.setOrientation(LinearLayout.VERTICAL);
    vertical.setBackgroundResource(R.drawable.rounded_layout);
    LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    p.setMargins(10, 10, 10, 10);
    vertical.setLayoutParams(p);
    vertical.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(link));
            startActivity(browserIntent);   
        }
    });
    TextView textTitle = new TextView(this);
        if (SPM.getFix()) {
            textTitle.setGravity(Gravity.LEFT);
        }
        else {
            textTitle.setGravity(Gravity.RIGHT);
        }
        textTitle.setTextSize(1, 18);
        textTitle.setText(Html.fromHtml("<font color='#92b64a'>"+title+"</font><br />"));
        vertical.addView(textTitle);

        TextView textDescription = new TextView(this);
            if (SPM.getFix()) {
                textDescription.setGravity(Gravity.LEFT);
            }
            else {
                textDescription.setGravity(Gravity.RIGHT);
            }
            String str = Html.fromHtml(description).toString();
            try{
                str = str.substring(0,str.lastIndexOf("\n\n"));
            }
            catch (IndexOutOfBoundsException e) { }
        textDescription.setText(Html.fromHtml(new RssOrganizer(str,false).getDescription()));
        vertical.addView(textDescription);

        TextView textpubDate = new TextView(this);
        if (SPM.getFix()) {
            textpubDate.setGravity(Gravity.LEFT);
        }
        else {
            textpubDate.setGravity(Gravity.RIGHT);
        }
        textpubDate.setText(new RssOrganizer(pubDate,true).getPubDate()+"\n\n");
        vertical.addView(textpubDate);
        homeLayout.addView(vertical);
    }
  • 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-06-01T18:07:07+00:00Added an answer on June 1, 2026 at 6:07 pm

    onProgressUpdate(...) runs on the UI thread so it shouldn’t do a lot of time-consuming work – that defeats the use of AsyncTask in the first place.

    Ideally onProgressUpdate(...) should simply provide basic progress updates such as percent complete or perhaps simple text messages indicating progression.

    All views used to show progression should be created beforehand however, many people use onPreExecute() for this.

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

Sidebar

Related Questions

I have an AsyncTask and on the background I want to start Service that
I have an AsyncTask that get info from the web. Sometimes the connection fails
I have AsyncTask that processes some background HTTP stuff. AsyncTask runs on schedule (Alarms/service)
I have an asynctask that reads data from a device and then I want
I have some AsyncTask that loads a video stream into the player, so I
So I have this AsyncTask that loads a WebView in onPostExecute that otherwise works
My goal is to have an AsyncTask that can execute multiple times (one task
I have a class that extends AsyncTask , which fetches the gps cordinates from
I have a class that extends AsyncTask. In the doInBackground() method, I connect to
I have an Activity class which has an attribute that references an AsyncTask instance

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.