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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:10:06+00:00 2026-05-25T15:10:06+00:00

This code worked when I had it in the UI thread but wanted to

  • 0

This code worked when I had it in the UI thread but wanted to move it into a AsyncTask class. I have just finished reading up how to do this but when I run the app it is now crashing when it starts reading the class.

The class calls and parses an XML files before loading it into a List. This is my first Android app, so any help you can provide is appricated.

Thanks

public class DownloadXml extends AsyncTask<String, Void, String>
{       
    private ProgressDialog pd;
    protected String doInBackground(String... platform) 
    {
        pd = ProgressDialog.show(CategoryData.this, "Please Wait...", "Loading games");

        try
        {
            BaseFeedParser parser = new BaseFeedParser();
            messages = parser.parse();
        }
        catch (Throwable t)
        {
            Log.e("RetailApp",t.getMessage(),t);
        }
        return rowPlatform;
    }


    protected void onPostExecute(String rowPlatform)
    {
        productList = new ArrayList<HashMap<String, Object>>();

            for (Message msg : messages)
            {   
                if(msg.getPlatform().compareTo(rowPlatform) == 0 )
                {   
                    HashMap<String, Object> map = new HashMap<String, Object>();
                    map.put("Title", msg.getTitle());
                    map.put("Brand", msg.getBrand());
                    map.put("Price", "$" + msg.getPrice());

                    try
                    {
                        String picture[] = msg.getImage().split("-large.jpg");
                        URL pictureURL = new URL(picture[0] + "-medium.jpg");
                        Bitmap bitmap = BitmapFactory.decodeStream(pictureURL.openStream());
                        map.put("Img",bitmap);
                    }
                catch (Throwable t)
                {
                    Log.e("RetailApp",t.getMessage(),t);
                }
                productList.add(map);
                } 
            }

Edit: I have moved the ‘for’ loop into onPostExecute and that seems to improve the code but I am still receiving a ‘unregistered handle still locked’ error. Any ideas?

Thanks for the idea Rob but no luck, have removed loop and Toast from background… new code above. Am receiving the error “Uncaught handler: thread AsycTask #1 exiting due to uncaught exception”

  • 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-25T15:10:07+00:00Added an answer on May 25, 2026 at 3:10 pm

    Use your LogCat. The AndroidRuntime log will give you a full stack trace and a strongly typed exception that will show you exactly why it crashed.

    I’m pretty sure it’s the fact that you’re trying to show a ProgressDialog from the background thread. You should do that on the UI thread just before you execute your AsyncTask. You can dismiss it in onPostExecute, since that runs back on the UI thread

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

Sidebar

Related Questions

I ran this persons code. It worked as a main but when i put
I had written this code out using Adobe CS3 and have recently upgraded to
A co-worker asked about some code like this that originally had templates in it.
This is code that worked fine on Windows XP for years. User is not
This code does not seem to compile, I just need to write something to
This code produces a FileNotFoundException, but ultimately runs without issue: void ReadXml() { XmlSerializer
I wanted my app to had a fading picture first before going into another
I seem to have exactly the same problem as this person: http://forums.adobe.com/thread/618752 He also
I was reading this thread/post: https://stackoverflow.com/questions/262298/windows-c-ui-technology and am also wondering about a non .NET
This code in JS gives me a popup saying i think null is a

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.