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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:38:21+00:00 2026-06-09T13:38:21+00:00

In my android app, I download an image from the cloud. The download is

  • 0

In my android app, I download an image from the cloud. The download is performed in a thread and in that same thread I also set an image view with the newly downloaded image. After setting the image, I then call postinvalidate().

However the image does not immediately show up. Is there a way to make the redraw happen immediately? I need a way to trigger a drawing cycle.

  • 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-09T13:38:23+00:00Added an answer on June 9, 2026 at 1:38 pm

    Each class which is derived from the View class has the invalidate() and the postInvalidate() method. If invalidate() gets called it tells the system that the current view has changed and it should be redrawn as soon as possible. As this method can only be called from your UIThread another method is needed for when you are not in the UIThread and still want to notify the system that your View has been changed. The postInvalidate() method notifies the system from a non-UIThread and the View gets redrawn in the next eventloop on the UIThread as soon as possible.

    In your case you can achieve what you want with the help of AsyncTask (an intelligent backround thread).AsyncTask enables proper and easy use of the UI thread. This class allows to perform background operations (download image in background in your case) and publish results (set your bitmap to your ImageView) on the UI thread without having to manipulate threads and/or handlers.

    An asynchronous task is defined by a computation that runs on a background thread and whose result is published on the UI thread. An asynchronous task is defined by 3 generic types, called Params, Progress and Result, and 4 steps, called begin, doInBackground, processProgress and end, as explained in the docs:

    The 4 steps

    When an asynchronous task is executed, the task goes through 4 steps:

    onPreExecute(), invoked on the UI thread immediately after the task
    is executed. This step is normally used to setup the task, for
    instance by showing a progress bar in the user interface before
    downloading the image from cloud and that’s used to provide a good
    user experience .

    doInBackground(Params...), invoked on the background thread
    immediately after onPreExecute() finishes executing. This step is used
    to perform background computation that can take a long time. The
    parameters of the asynchronous task are passed to this step. The
    result of the computation must be returned by this step and will be
    passed back to the last step. This step can also use
    publishProgress(Progress…) to publish one or more units of progress.
    These values are published on the UI thread, in the
    onProgressUpdate(Progress…) step.

    onProgressUpdate(Progress...), invoked on the UI thread after a call
    to publishProgress(Progress...). The timing of the execution is
    undefined. This method is used to display any form of progress in the
    user interface while the background computation is still executing.

    onPostExecute(Result), invoked on the UI thread after the background
    computation finishes. The result of the background computation is
    passed to this step as a parameter in that method you can set the
    bitmap to your imageView and invalidate your views

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

Sidebar

Related Questions

In my Android app I use a thread to download an image from the
In my Android App when I am try to download image file from Amazon
I need to write an Android app that would download sounds from the internet
I want to download an image from an android app. However, in the app
I want to download an image from my server to an Android app. I
I have a problem regarding Android App. I have created an application that download
I want to download an image from the 'net and set it as the
I'm using an API in my Android app that downloads images from the web
I have an Android app that fetches data from the web service using ksoap2,
We have an Android app and a Web Service. We want to download part

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.