1

I have a big problem... Finally finished my app, but can't distribute it because on some phones wallpaper quality is bad. I'm testing my app on Note 4, Galaxy S4 and Galaxy S2. Note4 and S2 wallpaper quality is perfect but with S4 (think there will be more phones with such a problem) I don't know what to do. Tried lot of different ways to set wallpaper, with crop, with options, directly without crop and options, jpg, png, but every time is the same result, even with android wallpaper set it's the same. Thank you for any help. There is screen shoots and simple code to set wallpaper:

imgur.com/3hngfbm Note4 - upscale with PS from 2160x1920 to 2880x2560 JPG (can't post 3 links)

S4 - 2160x1920 JPG

S2 - downscale with PS from 2160x1920 to 960x800 JPG

    public void setWallpaper() {

    WallpaperManager myWallpaperManager = WallpaperManager.getInstance(getActivity().getApplicationContext());
    Bitmap bmp = BitmapFactory.decodeStream(getResources().openRawResource(R.raw.img6));

    try {
        myWallpaperManager.setBitmap(bmp);
        Toast.makeText(getActivity().getApplicationContext(), "Set wallpaper successfully!", Toast.LENGTH_SHORT).show();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

Edit: I checked this wallpaper on another S4 but it is rooted and with Cyanogenmod Marshmallow. Quality is perfect like on Note 4 and S2. That S4 with bad quality have android 5.0.1

  • go through this http://stackoverflow.com/questions/2025282/difference-between-px-dp-dip-and-sp-on-android – sushildlh May 27 '16 at 05:53

1 Answers1

1

Perhaps it's a phone resolution problem. Have you tried placing different image sizes in your project? Android has set this to support multiple screen sizes, meaning that different resolutions of phones will be accessing the appropriate image size.

Try to look at this: https://developer.android.com/guide/practices/screens_support.html You must also place them with the same image name. And Android will access them automatically for you. Try to place them in the appropriate folders indicated in the link.


Or why not skip the bmp conversion? Like this:

public void setWallpaper() {
    WallpaperManager myWallpaperManager = WallpaperManager.getInstance(getApplicationContext());
        try {
            myWallpaperManager.setResource(R.drawable.img6);
            Toast.makeText(getActivity().getApplicationContext(), "Set wallpaper successfully!", Toast.LENGTH_SHORT).show();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
}

And make sure you add this in the manifest:

<uses-permission android:name="android.permission.SET_WALLPAPER"/>
berdi9
  • 23
  • 12
  • I was tried to scale images from 4k to all phones by programming, but more scale more quality was bad so decided to scale with photoshop and put images to all drawables. All phones wallpapers are perfect but galaxy s4 is like in the screen shoot. – Andrius Jurgelevičius May 27 '16 at 06:12
  • S4 size is normally 1080 by 1920, try to use this and replace the 2160 by 1920 you placed in your drawable. When the image is too big for a screen, it sometimes pixelates a rather HD image. – berdi9 May 27 '16 at 06:22
  • That is curious. Are you sure you placed is in the drawable-xhdpi folder? If yes, try to refer to this [link](http://stackoverflow.com/questions/5889507/why-is-my-imported-png-such-low-quality) – berdi9 May 27 '16 at 06:44
  • Yes i'm sure, but it takes from drawable-xxhdpi. I just tried everything from that link and the quality are not changing. – Andrius Jurgelevičius May 27 '16 at 07:34
  • I have added a code in my answer, try to check it out. – berdi9 May 27 '16 at 07:44
  • with setResource and drawables i get error "Expected recourse of type raw", i put image to raw folder (R.raw.img1), but no difference, the same quality. I don't know if there is any difference but universal image loader are displaying that image perfectly in imageView. – Andrius Jurgelevičius May 27 '16 at 08:05
  • Can you take a snapshot of your drawables with files on the xxhdpi, xhdpi and so on expanded? – berdi9 May 27 '16 at 08:07
  • http://i.imgur.com/eHPi3Fb.jpg i deleted other images that all files fit in snapshot. – Andrius Jurgelevičius May 27 '16 at 08:25
  • What wallpaper file are you trying to access again? It should be in drawable, not in raw. I am confused now as I don't see a common image file name in your drawable-xxhdpi, drawable- xhdpi etc. If the wallpaper name is img1.jpg for example, it must be available **with the same name** as in the rest of the drawable folders. If it is in raw, Android won't be able to adjust with the screen size of the phone. – berdi9 May 27 '16 at 08:31
  • img1.jpg i leaved only this file in drawable-xxhdpi folder for short expanded list. There is img1-img24 in all drawable folders. – Andrius Jurgelevičius May 27 '16 at 08:43
  • Yes real code is drawable. int resourceId = R.drawable.img1; wallUtils.setResourceAsWallpaper(resourceId); – Andrius Jurgelevičius May 27 '16 at 08:57
  • I edited my question. It seems like the problem is with android 5.0.1 version and not with my app. S2 is rooted with Marshmallow and Note 4 have 5.1.1 version. – Andrius Jurgelevičius May 30 '16 at 04:45