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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:45:15+00:00 2026-06-06T11:45:15+00:00

UPDATE: After searching a bit I don’t seem to be alone about this problem:

  • 0

UPDATE:

After searching a bit I don’t seem to be alone about this problem:

http://code.google.com/p/android/issues/detail?id=6066

https://groups.google.com/forum/?fromgroups#!topic/android-beginners/dDnHEacrpCE

There’s two solutions ATM:

1.
(Only works in some cases) Before calling the static decodeStream() method, implement a Thread.sleep(300) (Maybe the sleep duration value have to be higher, but 300 ms works for me)

2.
Replace the following:

URL pictureurl = new URL("http://www.somewebsite.com/picture15.jpg");
URLConnection urlConn = pictureurl.openConnection();
urlConn.connect();
InputStream urlStream = urlConn.getInputStream();

with the following (As suggested by imran khan):

HttpGet httpRequest = new HttpGet();
httpRequest.setURI(new URI("http://www.somewebsite.com/picture15.jpg"));
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = (HttpResponse) httpclient.execute(httpRequest);
HttpEntity entity = response.getEntity();
BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity);
Bitmap bm = BitmapFactory.decodeStream(bufHttpEntity.getContent());
httpRequest.abort();

I therefore accept imran khan’s answer, as it’s the only answer of all the answers in this post that’s working.


I have the following code in my Android app:

URL pictureurl = new URL("http://www.somewebsite.com/picture15.jpg");

URLConnection urlConn = pictureurl.openConnection(); // NOT NULL
urlConn.setRequestProperty("Referer", "http://www.somewebsite.com/");
urlConn.connect();
InputStream urlStream = urlConn.getInputStream(); // NOT NULL

Bitmap bm = BitmapFactory.decodeStream(urlStream);
Bitmap bm2 = Bitmap.createScaledBitmap(bm, 100, 100, true);

imageView.setImageBitmap(bm2);

The method “decodeStream()” returns null, when I use a certain image from a certain website but when I load the image in my browser it shows up just fine.
I can use other images from other websites that result in the method “decodeStream()” returning the expected Bitmap instance.

I noticed the following text in the method explanation of the “decodeStream()” method:

“If the input stream is null, or cannot be used to decode a bitmap, the function returns null” – My input stream is NOT null!

Following picture results in the method “decodeStream()” returning null:

http://i45.tinypic.com/eah2d2.jpg

Following picture results in the method “decodeStream()” returning the expected bitmap instance:

https://upload.wikimedia.org/wikipedia/commons/thumb/f/f9/Wiktionary_small.svg/350px-Wiktionary_small.svg.png

I am using Android 1.5.

Is this a bug in the Android/Java environment or am I doing something wrong?

  • 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-06T11:45:20+00:00Added an answer on June 6, 2026 at 11:45 am

    try following:

    HttpGet httpRequest = new HttpGet();
    httpRequest.setURI(new URI("http://www.somewebsite.com/picture15.jpg"));
    HttpClient httpclient = new DefaultHttpClient();
    HttpResponse response = (HttpResponse) httpclient.execute(httpRequest);
    HttpEntity entity = response.getEntity();
    BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity);
    Bitmap bm = BitmapFactory.decodeStream(bufHttpEntity.getContent());
    httpRequest.abort();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Update: After some more reading I see that this problem is totally general, you
There are a few posts about this, but after hours of searching I still
I have never really thought about this until today, but after searching the web
Update: After playing around with this for a few hours, went with a multi-query
After searching stackoverflow.com I found several questions asking how to remove duplicates, but none
UPDATED: 06.29.10 Here's the code I'm using so far. I'm really close after searching
After searching around i still have no clue about the best practice to reorder
This is not academic code or a hypothetical quesiton. The original problem was converting
I noticed this weird evaluation yesterday after searching for a few hours in my
Having trouble getting my form to UPDATE records in my database even after searching

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.