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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T19:44:42+00:00 2026-05-18T19:44:42+00:00

I have an android application i have been working on that downloads an image

  • 0

I have an android application i have been working on that downloads an image from a server, reads it into a bitmap and displays it on an ImageView

This works great most of the time, but every so often, it goes through the process (There is a ProgressDialog saying “Fetching image…”) and once its done nothing gets displayed. There has not been anything in logcat that even seems to remotely relate to this.

Here is the code:

    Bitmap image = null;

    HttpClient client = new DefaultHttpClient();
    HttpGet get = new HttpGet(webService + "?cmd=get");

    try
    {
        HttpResponse resp = client.execute(get);

        Log.i("PhotoRouletteDebug", "Resp buffer size: " + (int)resp.getEntity().getContentLength());
        InputStream is = resp.getEntity().getContent();

        BufferedInputStream buf = new BufferedInputStream(is, (int)resp.getEntity().getContentLength());

        image = BitmapFactory.decodeStream(buf);

        // clean up
        buf.close();
        is.close();

Even when nothing is getting displayed, the Resp content length always reports a correct size but still, nothing ends up getting displayed.

This code is called from an AsyncTask, but only 1 task is ever called at a time.

This is driving me insane, i have no idea why its keeps doing this.

Edit: Here is the code that sets the imageView

// AsyncTask for Getting a new image from the queue
protected class GetImageTask extends AsyncTask<String, String, Bitmap>
{
    protected void onPreExecute()
    {
        // lets show a progress dialog so the user knows something is going on
        progressDialog = ProgressDialog.show(PhotoRoulette.this, "", "Fetching image...", true);
    }

    protected void onPostExecute (Bitmap image)
    {
        // we got a new photo so lets display it where it needs to be displayed
        try
        {
            photoView = (ImageView)findViewById(R.id.photoView);
            photoView.setImageBitmap(image);
        }
        catch (Exception e)
        {
            Log.e("Debug", "Something absolutely retarded happened", e);
        }

        // hide the progress dialog - we're all done
        progressDialog.dismiss();
    }

    protected Bitmap doInBackground(String... urls)
    {
        // Get a new Bitmap Queue Image
        Bitmap image = imageHandler.getQueueImage();
        return image;
    }
}
  • 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-18T19:44:43+00:00Added an answer on May 18, 2026 at 7:44 pm

    You didn’t show us the code for displaying the image, so we don’t know for sure that that code is correct. Perhaps the problem lies there?

    But assuming that the problem is that the image is getting corrupted, here’s how I’d start debugging this: Wrap buf with a PushbackInputStream. Read the bytes out of buf and save them to a file; then push those same bytes back into the PushbackInputStream. Then pass the PushbackInputStream into BitmapFactory.decodeStream. If the image is displayed successfully, then delete the file (manually or programatically.) Otherwise, you can now examine the bitmap at your leisure.

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

Sidebar

Related Questions

I have an Android application that I've been working on, and it's implemented using
I have been working on creating an application that sends a string from an
I am learning Android and have been working on an application that will need
I have been trying to pull out my SQLite database from my android application
I have an android application that displays a toast every hour and then every
I have been working on a Android Web Services program that uses a number
I have a semester long project that I have been working on in Android
Good Evening, I have been trying to implement a simple Android(tm) application that utilizes
I have an Android application (java) that was working fine when compiled with the
I have been developing Android application for Android 3.x and now I want to

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.