Search code examples
androidwallpaper

Android: Get size of Wallpaper


I want to have the default size of the Wallpaper for the Crop Intent. Because then the user can crop the Image to the right size for the Wallpaper.

I tried it with

WallpaperManager.getInstance(getApplicationContext()).getDrawable().getMinimumHeight();//same for width

or

WallpaperManager.getInstance(getApplicationContext()).getDesiredMinimumHeight();//same for width

but on the Samsung Galaxy S4 mini it says 960x960 and this can't be. On my HTC One V it says 960x800 this could be, but I think this isn't exactly correct.

Do you know any way to find the Wallpaper size? It isn't enough to have the Screen Dimensions, because e.g. my HTC Wallpaper is bigger than the screen because the Wallpaper moves if you wipe to the left or the right.


Solution

  • You can try converting your Wallpaper to a Drawable and then get the width and height from it :

    WallpaperManager wpm = WallpaperManager.getInstance(getApplicationContext());
    Drawable d = wpm.getDrawable();
    int width = d.getIntrinsicWidth();
    int height = d.getIntrinsicHeight();
    

    or cast to a Bitmap :

    bmp = ((BitmapDrawable) d).getBitmap();
    width = bmp.getWidth();
    height = bmp.getHeight();