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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:54:41+00:00 2026-06-17T17:54:41+00:00

The idea is simple. Create a new TextView, attach it to ListView and then

  • 0

The idea is simple. Create a new TextView, attach it to ListView and then start downloading contents from a server. When there is no content downloading, the ListView is instantly updated. But after adding the TextView to the ListView I started downloading, refreshing listView on screen is done after the downloading is finished.

Main function

TextView startingDownloadingText = createTextView("Downloading started");
linearLayout.addView(startingDownloadingText);
boolean success = downloadFromUrl(stringUri, fileName, context);
if (success) {......

Function for downloading

public boolean downloadFromUrl(String stringURL, String fileName, Context myContext) { 

    try {
        URL url = new URL(stringURL);             
        Resources res = myContext.getResources();
        String envDirectory = Environment.getExternalStorageDirectory().toString();
        String zipDirectory = envDirectory.concat(res.getString(R.string.zipDirectory));

        File fileDirectory = new File(zipDirectory);
        fileDirectory.mkdirs();

        ZipDownloader zipDownloader = new ZipDownloader(zipDirectory, fileName);
        AsyncTask<URL, Void, Boolean> asynZipDownloader = zipDownloader.execute(url);
        Boolean success = null;
        try {
            success = asynZipDownloader.get();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
        if (success){
            Log.d("DownloadFromUrl", "file ready");
            return true;
        }
        return false;
    } catch (IOException e) {
        Log.e("DownloadFromUrl", "Error: " + e);
        return false;
    }

}

Why is this happening ?

UPDATE

AsyncTask<…>.get() is UI blocking and using onPostExecute() in AsyncTask will do the work in non blocking way. Example : android asynctask sending callbacks to ui

  • 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-17T17:54:43+00:00Added an answer on June 17, 2026 at 5:54 pm

    You appear to be downloading from the UI Thread, take a look at AsyncTask and try and implement that instead. See here

    When you request a download it blocks on the UI Thread until completed. If you put it into a separate AsyncTask then this frees up your UI Thread and you can call back into the UI Thread to provide the result and update your UI

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

Sidebar

Related Questions

I frequently start with a simple console application to try out an idea, then
I'm developing a control which inherits from a System.Windows.Form.Panel. The idea is very simple:
I have all the default settings from paperclip's website. When I create a new
So my simple idea is to create an app that allows the user to
The idea is simple: create a web part page in SP Designer 2010 that
I have a requirement to create a simple menu/selection design tool - the idea
I try to make a simple message controller with new/create actions, when I call
The idea is simple. Make a struct for Departments of a store, give it
OK, the idea is simple. Every wordpress site is uses categories and tags taxonomies
So, my idea is quite simple: print all of the possible combinations given X

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.