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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:20:28+00:00 2026-05-26T08:20:28+00:00

I need to implement progress bar in an android project when an intent is

  • 0

I need to implement progress bar in an android project when an intent is passed through one activity another, and some a fair bit of data from the internet is being downloaded in second activity and as such there is a noticeable delay between when the user clicks on an item and when the Activity displays.

I’ve tried a few different approaches for this but nothing seems to work as desired. I am using the following code for it. And the progress dialog is going inside infinite loop.

          public class BackgroundAsyncTask extends AsyncTask<String, Integer, Bitmap> {

          int myProgress;

          @Override

          protected void onPostExecute(Bitmap result) {
              iv.setVisibility(View.VISIBLE);
              iv.setImageBitmap(result);
              dialog.cancel();
              dialog.dismiss();
          }

          @Override
          protected void onPreExecute() {
            dialog = ProgressDialog.show(ProfileNormalUserPhotos.this, "Loading...", "Please wait...");

          }

          @Override
          protected Bitmap doInBackground(String...paths) {
             return DownloadFile(imageUrl);

         }
          @Override
          protected void onProgressUpdate(Integer... values) {
           // TODO Auto-generated method stub
           progressBar.setProgress(values[0]);
          }

         }

    public Bitmap DownloadFile(String url){
        URL myFileUrl;
         Bitmap bitmap=null;
        try {

            myFileUrl = new URL(imageUrl);
         HttpURLConnection conn= (HttpURLConnection)myFileUrl.openConnection();
         conn.setDoInput(true);
         conn.setConnectTimeout(10000);
         conn.setReadTimeout(10000);
         conn.connect();
         InputStream is = conn.getInputStream();
         bmImg = BitmapFactory.decodeStream(is);
         bitmap = BitmapFactory.decodeStream((InputStream) new URL(  
         imageUrl).getContent()); 
        bitmap = Bitmap.createScaledBitmap(bitmap,70 , 70, true);
        System.out.println("name of bitmap"+bitmap.toString());

        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            System.out.println(e);
        }
        return bitmap;

    }

And following is my adapter class

             public class ImageAdapter extends BaseAdapter {  
                Context mContext;
    private String[] stringOnTextView;

     public ImageAdapter(Context c) {  
      mContext = c;  
     }  
    // BitmapManager.INSTANCE. setPlaceholder(BitmapFactory.decodeResource(  
     //           context.getResources(), R.drawable.icon));  


    public ImageAdapter(Context Context,
            String[] stringOnTextView) {
        this.mContext=Context;
        this.stringOnTextView=stringOnTextView;
    }

    public int getCount() {  
      return stringOnTextView.length;  
     }  


    public Object getItem(int position) {  
      return null;  
     }  

     public long getItemId(int position) {  
      return position;  
     }  


     public View getView(int position, View convertView, ViewGroup parent) {

        System.out.println("**************"+position);

         View v = null;
        if(convertView==null){


            try{

            {
                  System.gc();
                // dialog = ProgressDialog.show(ProfileNormalUserPhotos.this, "Loading...", "Please wait...");
                  imageUrl = "http://ondamove.it/English/images/users/";
                  imageUrl=imageUrl+stringOnTextView[position];
                  System.out.println(imageUrl);

                  LayoutInflater li = getLayoutInflater();
                  v = li.inflate(R.layout.icon, null);
                  TextView tv = (TextView)v.findViewById(R.id.text);
                  tv.setText("Profile Image "+(position+1));
                  /* URL myFileUrl = new URL(imageUrl);
                   HttpURLConnection conn= (HttpURLConnection)myFileUrl.openConnection();
                   conn.setDoInput(true);
                   conn.setConnectTimeout(10000);
                   conn.setReadTimeout(10000);
                   conn.connect();
                   InputStream is = conn.getInputStream();

                   bmImg = BitmapFactory.decodeStream(is);
                   Bitmap bitmap = BitmapFactory.decodeStream((InputStream) new URL(  
                         imageUrl).getContent()); 

                    bitmap = Bitmap.createScaledBitmap(bitmap, 80, 80, true);*/

                    // new ImageView(mContext);
                   iv= (ImageView)v.findViewById(R.id.image);
                    new BackgroundAsyncTask().execute(imageUrl);
                    //iv.setImageBitmap(bitmap);
                    //dialog.cancel();

                    // System.out.println(bitmap.getHeight());

                     System.out.println("++++++++"+R.id.image);


                   }
           }catch (Exception e) {
            e.printStackTrace();
            System.out.println(e);
        }
        }
        else
        {
            try{
            v = convertView;}
            catch(Exception e){
                System.out.println(e);
            }
        }
        return v;
    }
}

Can anyone help me over this?

  • 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-26T08:20:28+00:00Added an answer on May 26, 2026 at 8:20 am

    Try AsyncTask,

     private class myAsyncTask extends AsyncTask<String, Void, Void>
        {
            ProgressDialog mProgressDialog;
            @Override
            protected void onPreExecute() {
                mProgressDialog = ProgressDialog.show(Activity_name.this, "Loading...", "Please wait...");
            }
            @Override
            protected Void doInBackground(String... params) {
    
                        String url = params[0];
                //  you can do download from internet here
                return null;
            }
            @Override
            protected void onPostExecute(Void result) {
                mProgressDialog.dismiss();
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to implement some kind of metric space search in Postgres(*) (PL or
I'm using QT to implement some UI program. In this program I need a
I need help on implementing a circular progress bar like this: How should I
I need a progress bar for a php script. As for now I choose
I'm currently loading a webpage using a thread and I need a progress bar
I need to implement some plot like that or that in my app ,
I have a project coded in .NET Winforms. I need to implement a data-mining
I need to implement a Diff algorithm in VB.NET to find the changes between
I need to implement version control, even for just the developing I do at
I need to implement a 4-to-1 function in Veriog. The input is 4 bits,

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.