Android: SkImageDecoder Factor returned null - Bitmap returns null
<p>I'm downloading an image from a URL and my application did that just fine. Then I decided to add a <code>ProgressBar</code> to indicate that the image is downloading etc. The <code>ProgressBar</code> shows fine but once it reaches 100%, I'm left with a blank screen instead of the image I downloaded. I gett he error message </p>

<blockquote>
  <p>SkImageDecoder Factor returned null.</p>
</blockquote>

<p>I debugged and it seems <code>bmp = BitmapFactory.decodeStream(in, null, bmpOptions);</code> returns null and I can't seem to figure out why. </p>

<p>Any help would be greatly appreciated.</p>

<pre><code>public class Gallery extends Activity {

    private ProgressDialog progressBar;
    public static final int progressBarType = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.gallery_zoom);

        new backgroundLoader().execute();
    }

    private class backgroundLoader extends AsyncTask&lt;String, String, String&gt; {
        Bitmap bmp;

        @SuppressWarnings("deprecation")
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            showDialog(progressBarType);
        }

        @Override
        protected String doInBackground(String... params) {
            BitmapFactory.Options bmpOptions;
            bmpOptions = new BitmapFactory.Options();
            bmpOptions.inSampleSize = 2;

            int count;

            try {
                URL url = new URL(getIntent().getStringExtra("image"));

                HttpURLConnection connection = (HttpURLConnection) url
                        .openConnection();
                int fileLength = connection.getContentLength();

                InputStream in = new BufferedInputStream(
                        connection.getInputStream(), 8192);

                byte data[] = new byte[1024];
                long total = 0;
                while ((count = in.read(data)) != -1) {
                    total += count;
                    publishProgress("" + (int) ((total * 100) / fileLength));
                }

                bmp = BitmapFactory.decodeStream(in, null, bmpOptions);
                in.close();

            } catch (Exception exception) {
                exception.printStackTrace();
                return null;
            }

            return null;
        }

        @Override
        protected void onProgressUpdate(String... values) {
            super.onProgressUpdate(values);
            progressBar.setProgress(Integer.parseInt(values[0]));
        }

        @SuppressWarnings("deprecation")
        @Override
        protected void onPostExecute(String result) {
            super.onPostExecute(result);
            dismissDialog(progressBarType);

            ImageView image = (ImageView) findViewById(R.id.imageZoom);
            image.setImageBitmap(bmp);
        }
    }

    protected Dialog onCreateDialog(int id) {
        switch (id) {
        case progressBarType:
            progressBar = new ProgressDialog(this);
            progressBar.setMessage("Downloading image. Please wait...");
            progressBar.setCancelable(true);
            progressBar.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
            progressBar.setProgress(0);
            progressBar.setMax(100);
            progressBar.show();
            return progressBar;
        default:
            return null;
        }
    }
}
</code></pre>
