0

I am developing wallpaper application with set as wallpaper option. I am displaying all images into grid view from Photos directory located on sdcard. when user click any of the image thumbnail it opens up into full screens view where i have provided set as wallpaper option. every thing is working fine. Now the problem is that i want to provide cropping functionality with an option to set image in full screen view without zooming or stretching. i tried many codes but it did not work as per my expectation. I am calling the following function on click event. the below is the code that i have tried but it stretches the image.

enter code here
private void setWallPaper() {
    WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
    try {
        //set for full screen wallpaper
        DisplayMetrics metrics = new DisplayMetrics(); 
        getWindowManager().getDefaultDisplay().getMetrics(metrics);
        int fullHeight = metrics.heightPixels; 
        int fullWidth = metrics.widthPixels;
        Bitmap bitmapResized = Bitmap.createScaledBitmap(imageBitmap, fullWidth, fullHeight,true);
        wallpaperManager.setBitmap(bitmapResized);

        //wallpaperManager.setBitmap(imageBitmap);
        Toast toast = Toast.makeText(this, "Set wallpaper successfully!", Toast.LENGTH_LONG);
        toast.show();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

is there any way to bypass this cropping functionality and set image as full screen? Please help me in this regard. thanks in advance.

1 Answers1

0

So far as I know, you will have to create your own Live Wallpaper service for that level of control. There's a thorough example here. Creating your own service will let you add other features like touch scroll, etc. (though you have to make some workarounds for Samsung devices who disable this functionality via the TouchWiz layer). It seems a pain, but it doesn't take that long to setup a basic Live Wallpaper service.

JASON G PETERSON
  • 2,193
  • 1
  • 18
  • 19