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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:47:04+00:00 2026-06-13T00:47:04+00:00

in my app when a particular activity is been called i am showing a

  • 0

in my app when a particular activity is been called i am showing a image from an url. As the image from url will gets loaded slowly, i am trying to show a progress dialog here,

following is my code to show progress dialog beofr image appears

class ShowImageTagList extends AsyncTask<Void, Void, Void> 
{
     ProgressDialog dialog = new ProgressDialog(UploadPhoto.this);
     protected void onPreExecute() 
     {
          Log.e("preexcute ","called");
          this.dialog.setMessage(" Loading ...");
          this.dialog.setCancelable(false);
          this.dialog.show();
     }

     protected Void doInBackground(Void... args) 
     {
        try
        {   
            JSONObject json = new JSONObject(Appconstants.photo_details);
            JSONArray photoperson = json.getJSONArray("photopersons");
            Log.e("photoperson ","value @ photoperson "+photoperson);
            for(int j=0; j < photoperson.length(); j++)
            {
               id.add(photoperson.getJSONObject(j).getString("pid").toString());
               names.add(photoperson.getJSONObject(j).getString("name").toString());
            }
         }
         catch(Exception e)
         {
             Log.e("Eception caught", ""+e);
         }
         return null ;      
      }

      protected void onPostExecute(Void unused) 
      {
           Log.e("post execute ","called");
           Bitmap bm = getBitmapFromURL(Appconstants.image_url.get(Appconstants.img_i));
           img_to_upload.setImageBitmap(bm);
           list_tag.setAdapter(new ListviewAdapter(UploadPhoto.this, names, id));
           dialog.dismiss();
      }
}

public static Bitmap getBitmapFromURL(String src) 
{
    try 
    {
       URL url = new URL(src);
       HttpURLConnection connection = (HttpURLConnection) url.openConnection();
       connection.setDoInput(true);
       connection.connect();
       InputStream input = connection.getInputStream();
       Bitmap myBitmap = BitmapFactory.decodeStream(input);
       return myBitmap;
    }
    catch (IOException e)
    {
        e.printStackTrace();
        Log.e("Exception",e.getMessage());
        return null;
    }

}

The progress dialog does not appear immediately, it takes to appear for micro second before the image gets appeared, but the logs in pre-execute and do in background gets printed immediately. when the asyn task been called,

how to make the progress to run from the begin…..

  • 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-13T00:47:05+00:00Added an answer on June 13, 2026 at 12:47 am

    move
    Bitmap bm = getBitmapFromURL(Appconstants.image_url.get(Appconstants.img_i));
    in

    doInBackground

    As it is the main long process. Which you are calling in onPostExecute.

    onPostExecute run on Main UI thread.

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

Sidebar

Related Questions

I am trying to write some Activity tests for an app, and one particular
I'm trying to increase the size of a particular textview from within the app.
I'm working on my Android app and I've got one Activity showing a list
I am trying use the onClick() function in an activity for an android app.
I'm opening the send menu from a button click in a particular activity: Intent
My app has started throwing errors when I try to save a particular class
I want my app to catch downloads of a particular kind of file. Here's
In particular, I am adding a compass to my app. I want to place
When I'm looking for a particular iPhone feature for my iPhone/iPad app, how do
This is more a general question but my particular case involves a ruby/rails app

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.