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

The Archive Base Latest Questions

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

So I have a little app I am working on that scrapes comics from

  • 0

So I have a little app I am working on that scrapes comics from the web and displays them on my phone. Nothing fancy, just using it to learn the ropes. The function called comicReload(); does most of the work and it is called many times in the application (on first run, and when the user clicks certain buttons. Here is the function:

public void comicReload () throws IOException {
    //clears some Vectors that have things in them from the last run
    imagetitles.clear();
    imagetext.clear();
    imagelinks.clear();

    //forms the link it will connect to, and connects
    connector = siteBase + Integer.toString(comicNumber);
    doc = Jsoup.connect(connector).get();
    media = doc.select("[src]");

    //gets the required media from the site
    for (Element src : media) {
        if (src.tagName().equals("img"));
            imagetitles.add(src.attr("alt"));
            imagetext.add(src.attr("title"));
            imagelinks.add(src.attr("src"));
    }

    //some variables I could probably get rid of, but it's easy to read
    Integer titlesize = imagetitles.size();
    Integer textsize = imagetext.size();
    Integer linkssize = imagelinks.size();

    comicTitle = (imagetitles.get(titlesize-4));
    hoverText = (imagetext.get(textsize-4));
    comicLink = (imagelinks.get(linkssize-4));

    //gets the picture I am looking for along with the associated text
    URL url = new URL(comicLink);
    InputStream is = (InputStream) url.getContent();
    image = Drawable.createFromStream(is, "src name");

    //finally puts the scraped information into the layout
    comicView.setImageDrawable(image);
    title.setText(comicTitle);
    htext.setText(hoverText);
}

It works 100% fine when it is called, but it’s a little slow over 3G so I tried to add a ProgressDialog to show while it loads. This is my attempt (this is the code that runs where I used to just have comicReload();)

pd = ProgressDialog.show(this, "Getting Comic", "Loading", true, false);
    new Thread(new Runnable() {  
           public void run() {
               try {
                   comicReload();
               } catch (IOException e) {
                   Log.i("ComicReloadFail","Sam");
               }
               pd.dismiss();
               return;
           }
    }).start();

The Thread itself runs fine, and when I put some random code to execute in place of the try-catch block with the comicReload(); in it everything goes dandy. The second I put the comicReload() back in there, however, running the app causes the ProgressDialog spinner to spin for a few seconds before the app force closes. What is causing this? And why does comicReload() stop working when it’s in a thread. I just want a way to execute that method with a spinner going while it works.

Thanks in advance guys, I know that was a lot to read.

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

    you can not do UI related updates in a different thread than the one that created the UI.

    try using Handler

    public static final Handler handlerVisibility = new Handler() {
        public void handleMessage(Message msg) {
            int visibility = msg.getData().getInt("visibility");
            view.setVisibility(visibility);
        }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an asp.net MVC web app that processes images and resizes them which
I have a little app that downloads stock prices and was working perfectly (for
I have a little app that I am working on with wxPython. I have
I currently am working on a little app that requests user info from my
I am working on a little WinForm app and have been trying to find
I have been working on a Windows Mobile app for a little while now
I have a little app that have by default youtube as homepage. You can
I have a little app up that has both CCLayer view and UIView. That
I have a little iOS5 app that shows images. I click on the image
I am learning flex and have written a little app with a TextArea that

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.