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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T22:32:02+00:00 2026-06-18T22:32:02+00:00

I have an error that only appears in froyo devices nullpointerexception in Bitmap.createScaledBitmap() java.lang.RuntimeException:

  • 0

I have an error that only appears in froyo devices

nullpointerexception in Bitmap.createScaledBitmap()

java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:200)
at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
at java.lang.Thread.run(Thread.java:1019)
Caused by: java.lang.NullPointerException
at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:344)
at com.varxstudio.beautifulwallpapersLite.Imagen.a(Unknown Source)
at com.varxstudio.beautifulwallpapersLite.g.a(Unknown Source)
at com.varxstudio.beautifulwallpapersLite.g.doInBackground(Unknown Source)
at android.os.AsyncTask$2.call(AsyncTask.java:185)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)

and here is the code any solution?? why only in froyo???
previously only used BitmapFactory.decodeStream(inputStream) to load images but I found a flusedInputStream method to do this but I still get the same error

private class DownloadDialog extends AsyncTask<Void, Void, Void> {

    ProgressDialog myDialog = null;
    int result = 0;

    @Override
    protected void onPreExecute() {
        myDialog = ProgressDialog.show(Imagen.this, "", advert);
        myDialog.setCancelable(true);
        return;
    }

    @Override
    protected Void doInBackground(Void... params) {
        result = setWallpaper(path);

        return null;
    }

    @Override
    protected void onPostExecute(Void result) {
        myDialog.dismiss();
        switch (result){
            ----
        }
        return;
    }
}

public int setWallpaper(String path) {          
    int width, height;
    Bitmap dbm, bm;         
    bm = null;
    dbm = null; 
    InputStream is = null;

    WallpaperManager wpm = WallpaperManager.getInstance(this);
    dis = getWindowManager().getDefaultDisplay();           

    if((wpm != null) && (dis != null)){ 
        height = dis.getHeight();
        width = (int) (height * 1.33);              

        try {           
            URLConnection conn = new URL(path).openConnection();                
            conn.connect();             
            is = conn.getInputStream();             

            if (is != null) {                   
                bm = BitmapFactory.decodeStream(new FlushedInputStream(is));                    
                dbm = Bitmap.createScaledBitmap(bm, width, height, false);
                wpm.setBitmap(dbm);                 
            }else {
                return 2;
            }

        } catch (MalformedURLException e) {                 
            e.printStackTrace();                
        } catch (IOException e) {               
            e.printStackTrace();                
        } finally {             
            if (is != null) {
                try {
                    is.close();
                }
                catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }           
        if(bm != null){
            bm.recycle();
        }
        if(dbm != null){
            dbm.recycle();  
        }           
    }else {
        return 1;
    }
    return 0;
}

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 b = read();
                if (b < 0) {
                    break;  // we reached EOF
                } else {
                    bytesSkipped = 1; // we read one byte
                }
            }
            totalBytesSkipped += bytesSkipped;
        }
        return totalBytesSkipped;
    }
}
  • 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-18T22:32:03+00:00Added an answer on June 18, 2026 at 10:32 pm

    You’ve got the NullPointerException because
    BitmapFactory.decodeStream(new FlushedInputStream(is)); returns null, Reasons why BitmapFactory.decodeStream(stream) returns null is because of the bad image..
    Bad Image in the sense make sure that your are returning the bitmap format supported by Android,(Example Android doesn't support tiff). And the second reason is because of the image Resolution, if the image resolution is too high that decoding fails..so make sure that you’ve small image.

    This is the question I have posted in the SO regarding the same..Bitmap failed to create using BitmapFactory.decodeArray

    I have faced the same problem earlier but I have over come it by using the tutorial provided by Android developers site Displaying Bitmaps Efficiently

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

Sidebar

Related Questions

I have a problem with an validation error that only appears on Windows Azure,
I got a very strange error on my android apk that only appears if
Im having headaches by trying to fix a small error that appears only in
I have an error that I can't solve... I correctly registered as an Apple
I have this error that is keeping me from moving forward. I basically have
I have an odd error that you guys will hopefully be able to help
I have a silly error that I am unable to resolve. I try to
I have a javascript error that occurs on my site, Im pretty sure I
I have a syntax error that I don't know how to fix. This is
Today, I have made an error that frustrated me for hours to see what

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.