White bitmap in android

Max Frai picture Max Frai · Dec 10, 2012 · Viewed 12.2k times · Source

I want to set home wallpaper with white bitmap:

    Bitmap bitmap = Bitmap.createBitmap(WIDTH, HEIGHT, Bitmap.Config.ARGB_8888);

    Canvas canvas = new Canvas(bitmap);
    canvas.drawColor(0xfff);

    WallpaperManager wall = WallpaperManager.getInstance(this);
    try {
        wall.setBitmap(bitmap);
    } catch (IOException e) {
        e.printStackTrace();
    }

And the wallpaper becomes black. What's wrong is here?

Answer

Alecs picture Alecs · Oct 18, 2015

Just add bitmap.eraseColor(Color.WHITE); as second line