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

The Archive Base Latest Questions

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

basically i am reading image bytes from file i have a loop which has

  • 0

basically i am reading image bytes from file i have a loop which has to read almost 20 images from file and in this loop i have making the object of my class which extends ASyncTask class and i am reading bytes and drawing on canvas in doItBackground() method and setting my image on onPostExecute() method. so basically Asynchronously 20 threads starts execution in background. now problem is it is not showing any image.

anybody have any idea how to handle multiple AsyncTask class? here is my code.

    @Override
    protected Void doInBackground(Void... params) 
    {
//      Log.i("start background thread", "start background thread");
        Set<Integer> keys;
        keys = iTileListOffsets.keySet();
        boolean found = false;
        Object key[] = keys.toArray();
        int k = 0;

        for (int i=0; i < key.length && found==false ; i++)
        {               
            k = (Integer) key[i];
            MapTileHeader tileHeader = iTileListOffsets.get(k);
            if (tileHeader.equalsWith(mapTile.getiMapTileHeader()) )
            {                   
                found = true; 
            }
        }

        if(found)
        {           
            try 
            {   
                synchronized (MapMaker.getSingletonObject()) 
                {
                    fc.position(0);                     
                    input.skipBytes(k);                         
                    int tSizeOfTile = input.readInt();              
                    mapTile.loadTileWithFileHeader(input, tSizeOfTile, headerBytesArray);
                }

                mapMaker.getBufferedTilesDataList().add(mapTile);                       
            }
            catch (Exception e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            byte imageTile[] = mapTile.getImageTilesBytes();             //bufferedTile.getImageTilesBytes();                   

            if(mapTile.getImageTilesBytes() != null)
            {                       
                try
                {
                    Bitmap tileBitmap = BitmapFactory.decodeByteArray(imageTile, 0, imageTile.length);
                    canvas.drawBitmap(tileBitmap, rect.left, rect.top, null);
                    tileBitmap = null;
                }
                catch(Exception e)
                {
                    e.printStackTrace();
                }                   
            }
        }
//      Log.i("ENDDDD background thread", "ENDDD background thread");
        return null;
    }

    @Override
    protected void onPostExecute(Void result)
    {
        // TODO Auto-generated method stub
        super.onPostExecute(result);        
        Log.i("start POSTECEXCUTE thread", "start POSTECEXCUTE thread");

        MyRect mapRect = aBufferArea.GetScreenRectangle(buffer, aScrnArea); 
        Bitmap smallBitmap = Bitmap.createBitmap(bitmap, mapRect.left, mapRect.top, mapRect.width, mapRect.height);         
        image.setImageBitmap(smallBitmap);

        Log.i("ENDDDDD POSTECEXCUTE thread", "ENDDDD POSTECEXCUTE thread");
    }

thanks

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

    I dont think you can update the UI directly from doInBackground, as the code in this method is run in a backgound thread and does not have direct access to the IU thread. You can update the UI either from onPostExecute or from onProgressUpdate. You can call the latter of these from doInBackground by calling publishProgress.

    There is a simple example in the documentation for AsyncTask, and this one is a little more complex.

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

Sidebar

Related Questions

Basically what I want to do it this: a pdb file contains a location
Basically, something better than this: <input type=file name=myfile size=50> First of all, the browse
Basically I have some sort of third party software running on Windows 7 which
After reading some threads on misuses of exceptions (basically saying you don't want to
That's basically the question, is there a right way to implement operator<< ? Reading
Basically I have some code to check a specific directory to see if an
Basically I am trying to restart a service from a php web page. Here
Basically I'm going to go a bit broad here and ask a few questions
Basically, I would like a brief explanation of how I can access a SQL
Basically, I'm trying to tap into the Soap pipeline in .NET 2.0 - I

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.