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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:00:19+00:00 2026-05-25T13:00:19+00:00

i have searched for this exception everywhere but could not find a resolution &

  • 0

i have searched for this exception everywhere but could not find a resolution & any help would be appreciated.
i have tried putting break points, but they do not get hit, the error is also visible in log.v and not in log.e.
The code works for first few calls say for 10-12 times, then gets slower(starts failing with this error), and eventually throws this error every-time.

            _actionRunble = new Runnable() {
            public void run() {
                try{
                    ##..##
                     _imView.setImageBitmap(bmImg);
                     Drawable oldD = _imView.getBackground();
                     Drawable dd = new BitmapDrawable(bmImg);
                     _imView.setBackgroundDrawable(dd);
                     //(((BitmapDrawable)oldD).getBitmap()).recycle();
                     Thread t = new Thread(_r);
                     t.start();
                }catch(Exception e)
                {
                    e.printStackTrace();
                }
              }
           };
           _r = new Runnable() {
            @Override
            public void run() {
                downloadFile(imageUrl);
            }
           };
           Bitmap bmImg;
           void downloadFile(String fileUrl){
            URL myFileUrl =null;          
              try {
                   myFileUrl= new URL(fileUrl);
              } catch (MalformedURLException e) {
                   e.printStackTrace();
              }
              catch (Exception e) {
                   e.printStackTrace();
              }
              try {
                   HttpURLConnection conn= (HttpURLConnection)myFileUrl.openConnection();
                   conn.setDoInput(true);
                   conn.connect();
                   InputStream is = conn.getInputStream();

                   bmImg = BitmapFactory.decodeStream(is);
                   //this.runOnUiThread(_actionRunble);
                   _mHandler.postDelayed(_actionRunble, 2000);
                   //_mHandler.postAtFrontOfQueue(_actionRunble);
                   //_mHandler.post(_actionRunble);
              } catch (IOException e) {
                   e.printStackTrace();
              }
              catch (Exception e) {
                   e.printStackTrace();
              }
         }

activity oncreate calls downloadfile(…) and after return of the call i again call with the same url to get the updated image. I tried delaying the posting message on main queue by 2 secs(although i dont want that) but that doesnt works too 🙁 .
Please feel free for further clarification.

  • 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-25T13:00:20+00:00Added an answer on May 25, 2026 at 1:00 pm

    well i resolved it finally.
    To get rid of this exception in particular, i started using a single HttpURLConnection(reuse it until it fails, where u create it again), BUT with that i ran into “BitmapFactory.decodeStream returning null” problem, while doing “bmImg = BitmapFactory.decodeStream(is);
    ” This was due to the fact i cannot use the same inputstream over the same connection again, so i had to close it before using it again(is.close(), in.close()). but that dint work for some reason(i dont know!).
    finally instead of getting inputstream from HttpURLConnection (using conn.getInputStream() ) i directly get it from URL ( myFileUrl.openStream() ). BitmapFactory.decodeStream(is) still can return null sometimes(better to handle that case-ask me why 🙂 ), in which case i try the download again.
    here is the updated downloadFile(…) method, Hope it helps someone 🙂

      void downloadFile(String fileUrl){
                URL myFileUrl =null;          
                  try {
                       myFileUrl= new URL(fileUrl);
                  } catch (MalformedURLException e) {
                      //print exception;
                  }
                  catch (Exception e) {
                      //print exception;
                  }
                  try {
                       //InputStream in = conn.getInputStream();--avoid this, get it from url directly instead, unless u really need to read from httpconnection because u want to configure headers or some other reason.
                       InputStream in = myFileUrl.openStream();
                       InputStream is = new BufferedInputStream(in);
                       bmImg = BitmapFactory.decodeStream(is);
                       in.close();
                       is.close();
                       if(bmImg==null)
                       {
                            downloadFile(fileUrl);
                            return;
                       }
                       //this.runOnUiThread(_actionRunble);
                       //_mHandler.postAtFrontOfQueue(_actionRunble);
                       //_mHandler.post(_actionRunble);
                       _mHandler.postDelayed(_actionRunble, 1000);
                  }
    
                 catch (IOException e) {
                      downloadFile(fileUrl);
                      //print exception;
                  }
                  catch (Exception e) {
                      downloadFile(fileUrl);
                      //print exception;
                  }
    
             }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have searched for hours but could not find anything similar. The crash has
So I have searched for this but not finding anything about it and if
I have searched the Web for this, but with no luck. Any idea? Thanks.
I have searched through many times but have not seen this before. Probably really
I've searched for this a little but I have not gotten a particularly straight
I have searched the web for resolution of this error, but everything I have
I have searched around for an answer to this but can't find one. When
I have searched Google for the standalone Hibernate/Spring applications, but didn't find any useful
Preface: I am sure this is incredibly simple, but I have searched this site
I realize this is a basic question but I have searched online, been 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.