Garg's Garg's - 1 year ago 85
Android Question

Wallpaper not properly fit on Samsung devices

I want to set wallpaper through app for all device but problem is that my following approach work for Moto, sony, micromax but not properly fit for any samsung device like samsung S3, samsung duos, Tab etc, in these devices wallpaper is much zoom see in screenshots.

please guide me for solve this problem.

private void setMyWallpaper() {

WallpaperManager myWallpaperManager = WallpaperManager

DisplayMetrics metrics = new DisplayMetrics();

// get the height and width of screen
int height = metrics.heightPixels;
int width = metrics.widthPixels;

Drawable drawable = null;

if (who.equals("color"))
drawable = getResources().getDrawable(colorWallpaper[i]);
drawable = getResources().getDrawable(grayWallpaper[i]);
Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();

Bitmap wallpaper = Bitmap.createScaledBitmap(bitmap, width, height,true);
myWallpaperManager.suggestDesiredDimensions(width, height);
try {
Log.i("Wall", "Wallpaper set successfully ");
} catch (IOException e) {


Micromax canvas screenshot :-
Micromax canvas screenshot

Samsung S3 screenshot :
Samsung S3 screenshot

Answer Source

I solve this problem using call INTENT in place of WallpaperManager like this:

//load file

File file = new File(getGalleryPath());

if ( file.exists()) {
     Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
     intent.setDataAndType(Uri.fromFile(file), "image/jpeg");
     intent.putExtra("mimeType", "image/jpeg");
     this.startActivity(Intent.createChooser(intent, "Set as:"));
} else {
     Log.d("TEST", "file not exixts.");

// method for getting Image path

private static String getGalleryPath() {
    return Environment.getExternalStorageDirectory() + "/" + Environment.DIRECTORY_DCIM + "/MyImages/IMG-20160326-WA0083.jpg";   
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download