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

  • Home
  • SEARCH
  • 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 8414513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:11:32+00:00 2026-06-10T01:11:32+00:00

I’m using some services of a web service which usually returns JSON respones, but

  • 0

I’m using some services of a web service which usually returns JSON respones, but one service when I send the ID of a user returns a static GIF image (Not animated).

The procedure that I’m doing is:

1.Connect to web service using DefaultHttpClient
2.Convert the InputStream received to a String with this utilitary method:

public static String inputStreamToStringScanner(InputStream in) {

  Scanner fileScanner = new Scanner(in);
  StringBuilder inputStreamString = new StringBuilder();
  while(fileScanner.hasNextLine())
    inputStreamString.append(fileScanner.nextLine()).append("\n");
  fileScanner.close();

  return inputStreamString.toString();
}

3.Storage the converted received String to process the server response.

For the Image Service, when I see the string converted, it begins like this:
“GIF89a?��?�� …”

It’s a static GIF file.

I’m not being able to show the image in a ImageView, I have tried different things that I found in the web:

public void onPhotoFinished (String responseData) {

  InputStream is = new ByteArrayInputStream(responseData.getBytes());
  Bitmap bm = BitmapFactory.decodeStream(is);
  userImage.setImageBitmap(bm);
}

This is something else that I have also tried:

public void onPhotoFinished (String responseData) {

  InputStream is = new ByteArrayInputStream(responseData.getBytes());
  final Bitmap bm = BitmapFactory.decodeStream(new BufferedInputStream(is));
  userImage.setImageBitmap(bm);
}

This also doesn’t works:

public void onPhotoFinished (String responseData) {

  InputStream is = new ByteArrayInputStream(responseData.getBytes());
  Drawable d = Drawable.createFromStream(is, "src name");
  userImage.setImageDrawable(d);
}

Finally, this doesn’t work either:

public void onPhotoFinished (String responseData) {

  Bitmap bm = BitmapFactory.decodeByteArray(responseData.getBytes(), 0, responseData.getBytes().length);
  userImage.setImageBitmap(bm);
}

In Logcat I receive “decoder->decode returned false”

Nothing seems to work… any ideas of what is wrong?

Thanks!

  • 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-10T01:11:34+00:00Added an answer on June 10, 2026 at 1:11 am

    Finally, I resolved it with FlushedInputStream and using directly the Input Stream, avoiding the conversion to String:

    static class FlushedInputStream extends FilterInputStream { 
    
    public FlushedInputStream(InputStream inputStream) {
        super(inputStream);
    }
    
    @Override
    public long skip(long n) throws IOException { 
    
      long totalBytesSkipped = 0L;
      while (totalBytesSkipped < n) { 
        long bytesSkipped = in.skip(n - totalBytesSkipped);
        if (bytesSkipped == 0L) { 
          int byteReaded = read();
          if (byteReaded < 0) {
              break; 
          } else {
              bytesSkipped = 1;
          }
        }
        totalBytesSkipped += bytesSkipped;
      }
      return totalBytesSkipped;
    }
    
    }
    

    AND:

    Bitmap bitmapResponseData = BitmapFactory.decodeStream(new FlushedInputStream(is));
    

    Regards

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm making a simple page using Google Maps API 3. My first. One marker
I need to clean up various Word 'smart' characters in user input, including but
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text

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.