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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:28:27+00:00 2026-05-22T16:28:27+00:00

i want to donload image from server asynchronously but when i run it force

  • 0

i want to donload image from server asynchronously but when i run it force close….and gives msg on log cat… An error occured while executing doInBackground()…whats the problem pls help me..pls pls

public class artspacedetailShowingNow extends Activity implements OnClickListener {
    private int imageCounter = 0;

    private ProgressDialog bar;

    private ImageView imageLoader;
    private String[] imageList = {"http://www.artealdiaonline.com/var/artealdia_com/storage/images/argentina/directorio/galerias/ruth_benzacar/artistas/martin_di_girolamo._diosas/198915-1-esl-AR/MARTIN_DI_GIROLAMO._Diosas.jpg","http://www.artealdiaonline.com/var/artealdia_com/storage/images/argentina/directorio/galerias/ruth_benzacar/artistas/jorge_macchi._la_espera/198929-1-esl-AR/JORGE_MACCHI._La_espera.jpg","http://www.artealdiaonline.com/var/artealdia_com/storage/images/argentina/directorio/galerias/ruth_benzacar/artistas/leon_ferrari._hongo_nuclear/198950-1-esl-AR/LEON_FERRARI._Hongo_Nuclear.jpg","http://www.artealdiaonline.com/var/artealdia_com/storage/images/argentina/directorio/galerias/ruth_benzacar/artistas/martin_sastre._fiebre/198922-1-esl-AR/MARTIN_SASTRE._Fiebre.jpg"};
        public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.showingnow);
           imageLoader = (ImageView) findViewById(R.id.imageLoader);
        //imageLoader.setImageResource(image1);

        Button next = (Button) findViewById(R.id.next);
        Button back = (Button) findViewById(R.id.back);
        next.setOnClickListener(this);
        back.setOnClickListener(this);
        back.setEnabled(false);

        new ImageDownload().execute(imageList[imageCounter]); 


    }
@Override
 public void onClick(View v)
{
    String imagePath = null;
       // imagePath = imageList[imageCounter];


    }
    new ImageDownload().execute(imagePath);



}
private void loadImage(String imagePath)

{
      try {

          /* Open a new URL and get the InputStream to load data from it. */

          URL aURL = new URL(imagePath);
          URLConnection conn = aURL.openConnection();
          conn.connect();
          InputStream is = conn.getInputStream();

          /* Buffered is always good for a performance plus. */
          BufferedInputStream bis = new BufferedInputStream(is);

          /* Decode url-data to a bitmap. */
          Bitmap bm = BitmapFactory.decodeStream(bis);

          bis.close();
          is.close();
         imageLoader.setImageBitmap(bm);
         imageLoader.setImageBitmap(bm);
      } catch (IOException e) 
      {

          Log.e("DEBUGTAG", "Remote Image Exception", e);

      }

}
private class ImageDownload extends AsyncTask<String , Void, Void>
{
    @Override
    protected Void doInBackground(String... params) {
        loadImage(params[0]);


       return null;
   }


    @Override
    protected void onPostExecute(Void result) {


    }
    @Override
    protected void onPreExecute() {


    }

}
}
  • 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-22T16:28:28+00:00Added an answer on May 22, 2026 at 4:28 pm

    try this

          private class ImageDownload extends AsyncTask<String , Void, Void>
    {
        Bitmap imBitmap;
        @Override
        protected Void doInBackground(String... params) {
             try {
    
                  /* Open a new URL and get the InputStream to load data from it. */
    
                  URL aURL = new URL(params[0]);
                  URLConnection conn = aURL.openConnection();
                  conn.connect();
                  InputStream is = conn.getInputStream();
    
                  /* Buffered is always good for a performance plus. */
                  BufferedInputStream bis = new BufferedInputStream(is);
    
                  /* Decode url-data to a bitmap. */
                  Bitmap bm = BitmapFactory.decodeStream(bis);
                  imBitmap=bm;
                  bis.close();
                  is.close();
    
              } catch (IOException e) 
              {
    
                  Log.e("DEBUGTAG", "Remote Image Exception", e);
    
              }
    
    
           return null;
       }
    
    
        @Override
        protected void onPostExecute(Void result) {
        imageLoader.setImageBitmap(imBitmap);
                     imageLoader.setImageBitmap(imBitmap);
    
        }
        @Override
        protected void onPreExecute() {
    
    
        }
    
    }
    

    you cant use imageLoader.setImageBitmap(imBitmap); in doinBackground.

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

Sidebar

Related Questions

I want to Download An image from a remote server. But each time I
i want to display a image after downloading that image from a web-server i
I want to download an image from a remote server only if it is
I want to download an image from a remote server only if it is
I want to download a PDF file from a SQL Server database which is
I want to download an image from the 'net and set it as the
I want to download a file from server to a local host. i have
I want to download a lot of pictures from the server. How can I
I'm loading an image file from a web server, and then saving it to
i uploaded files into my server image folder. after upload want to display the

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.