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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:35:50+00:00 2026-06-16T19:35:50+00:00

I got this IOException error while downloading images from the server and it crashes

  • 0

I got this IOException error while downloading images from the server and it crashes my application. This only happens once in awhile, usually no error occur while downloading. I’m not really sure what causes this and why this happened. It would be a great help if some one can explain on this issue. Thank you in advance!

Logcat

01-03 17:23:13.136: E/AndroidRuntime(12597): java.lang.RuntimeException: An error occured while executing doInBackground()
01-03 17:23:13.136: E/AndroidRuntime(12597):    at android.os.AsyncTask$3.done(AsyncTask.java:200)
01-03 17:23:13.136: E/AndroidRuntime(12597):    at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
01-03 17:23:13.136: E/AndroidRuntime(12597):    at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
01-03 17:23:13.136: E/AndroidRuntime(12597):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
01-03 17:23:13.136: E/AndroidRuntime(12597):    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
01-03 17:23:13.136: E/AndroidRuntime(12597):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
01-03 17:23:13.136: E/AndroidRuntime(12597):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
01-03 17:23:13.136: E/AndroidRuntime(12597):    at java.lang.Thread.run(Thread.java:1019)
01-03 17:23:13.136: E/AndroidRuntime(12597): Caused by: java.lang.NullPointerException
01-03 17:23:13.136: E/AndroidRuntime(12597):    at     com.f.bb.GalleryScreen$DownloadFile.doInBackground(GalleryScreen.java:242)
01-03 17:23:13.136: E/AndroidRuntime(12597):    at com.f.bb.GalleryScreen$DownloadFile.doInBackground(GalleryScreen.java:1)
01-03 17:23:13.136: E/AndroidRuntime(12597):    at android.os.AsyncTask$2.call(AsyncTask.java:185)
01-03 17:23:13.136: E/AndroidRuntime(12597):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
01-03 17:23:13.136: E/AndroidRuntime(12597):    ... 4 more
01-03 17:23:20.792: E/WindowManager(12597): Activity com.f.bb.GalleryScreen has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@405b3e78 that was originally added here
01-03 17:23:20.792: E/WindowManager(12597): android.view.WindowLeaked: Activity com.f.bb.GalleryScreen has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@405b3e78 that was originally added here
01-03 17:23:20.792: E/WindowManager(12597):     at android.view.ViewRoot.<init>(ViewRoot.java:263)
01-03 17:23:20.792: E/WindowManager(12597):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:171)
01-03 17:23:20.792: E/WindowManager(12597):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:114)
01-03 17:23:20.792: E/WindowManager(12597):     at android.view.Window$LocalWindowManager.addView(Window.java:424)
01-03 17:23:20.792: E/WindowManager(12597):     at android.app.Dialog.show(Dialog.java:241)
01-03 17:23:20.792: E/WindowManager(12597):     at com.f.bb.GalleryScreen$DownloadFile.onPreExecute(GalleryScreen.java:272)
01-03 17:23:20.792: E/WindowManager(12597):     at android.os.AsyncTask.execute(AsyncTask.java:391)
01-03 17:23:20.792: E/WindowManager(12597):     at com.f.bb.GalleryScreen$1$1.run(GalleryScreen.java:121)
01-03 17:23:20.792: E/WindowManager(12597):     at android.app.Activity.runOnUiThread(Activity.java:3717)
01-03 17:23:20.792: E/WindowManager(12597):     at com.f.bb.GalleryScreen$1.onClick(GalleryScreen.java:85)
01-03 17:23:20.792: E/WindowManager(12597):     at android.view.View.performClick(View.java:2538)
01-03 17:23:20.792: E/WindowManager(12597):     at         android.view.View$PerformClick.run(View.java:9152)
01-03 17:23:20.792: E/WindowManager(12597):     at android.os.Handler.handleCallback(Handler.java:587)
01-03 17:23:20.792: E/WindowManager(12597):     at android.os.Handler.dispatchMessage(Handler.java:92)
01-03 17:23:20.792: E/WindowManager(12597):     at     android.os.Looper.loop(Looper.java:130)
01-03 17:23:20.792: E/WindowManager(12597):     at android.app.ActivityThread.main(ActivityThread.java:3687)
01-03 17:23:20.792: E/WindowManager(12597):     at java.lang.reflect.Method.invokeNative(Native Method)
01-03 17:23:20.792: E/WindowManager(12597):     at java.lang.reflect.Method.invoke(Method.java:507)
01-03 17:23:20.792: E/WindowManager(12597):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
01-03 17:23:20.792: E/WindowManager(12597):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
01-03 17:23:20.792: E/WindowManager(12597):     at dalvik.system.NativeStart.main(Native Method)
01-03 17:27:16.148: I/Process(12597): Sending signal. PID: 12597 SIG: 9

Code (AsyncTask)

    private class DownloadFile extends AsyncTask<String, Integer, String>{
    @Override
    protected String doInBackground(String... sUrl){

        Bitmap bm;
        InputStream in;
        if(downloadFailed == false){
            if (contentId != null && contentId.length>0){
                Log.i(TAG, "contentid.length:" +contentId.length);
                for (int i=0;i<contentId.length;i++){
                    if(helper.databaseChecking(useremail, contentId[i])){
                        Constant.CONTENT_ID = contentId[i]; 
                        Log.i(TAG, "contentId:" +contentId[i]);

                        Log.i(TAG, "Email:" +useremail);
                        Log.i(TAG, "Section ID:" +ssID);

                        downloadList = new String[contentId.length];


                        try{
                            in = new java.net.URL(downloadList[i]).openStream();
                            bm = BitmapFactory.decodeStream(new PatchInputStream(in));
                            File storage = new File(Environment.getExternalStorageDirectory() + File.separator + "/testing/");
                            Log.i(TAG,"storage:" +storage);
                            Log.i(TAG,"storage:" +storage.getAbsolutePath());
                            if(!storage.exists()){
                                storage.mkdirs();
                                }
                            String FileName = "/"+Constant.CONTENT_ID+".jpg"; 
                            FileOutputStream fos = new FileOutputStream(storage + FileName);
                            bm.compress(Bitmap.CompressFormat.JPEG, 85, fos);
                            String filepath = storage + FileName;
                            File filecheck = new File (filepath);
                            long fileSize = filecheck.length();
                            fos.flush();
                            fos.close();


                            Constant.IMAGE_EXIST = 1;
                            }
                        catch(IOException e1){
                        e1.printStackTrace();
                        downloadFailed = true;
                        }

                    }

                }
            }
        }
        return null;
    }
    @Override
    protected void onPreExecute(){
        super.onPreExecute();
        pDialog.setMessage("Downloading file. Please wait...");
        pDialog.show();
    }


    protected void onPostExecute(String result){
        super.onPostExecute(result);
        pDialog.dismiss();

        alertTitle = "Information";
        alertMessage = "Sync Completed. Click 'OK' to refresh page";
        dialogBox_intent();
        Constant.SYNC_COMPLETE = true;


    }
}
  • 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-16T19:35:51+00:00Added an answer on June 16, 2026 at 7:35 pm

    BitmapFactory.decodeStream() can return null. See the documentation, but one case is the image that was downloaded was corrupt. You should test bm != null prior to using any methods, such as bm.compress(...)

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

Sidebar

Related Questions

I got following error. java.lang.NullPointerException: lock == null while get json file from server.I
Got this error message while trying to load view: The model item passed into
Got this error message while trying to configure an entitydatasource in the designer: My
So I've got a thing like this: try{ServerSocket acceptor = new ServerSocket(4782);} catch(IOException e){System.err.println(ERROR:
After upgrade of cassandra from 0.8.2 to 0.8.4, got this error I have restarted
Got this code for a viewscroller from the apple developers site. @synthesize scrollView1, scrollView2;
Got this error on a big $_GET query in size ~9 000 symbols (they
I got this code from our frontend guy for headings: <h2 class=headline><span>Foobar</span></h2> The span
I've got a little problem while managing .txt files on Android. I've found this
I'm working on downloading a file on a software, this is what i got,

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.