Wallpaper not properly fit on device screen

Hello This is working with drawable image i have checked it.. DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int height = metrics.heightPixels; int width = metrics.widthPixels; Bitmap tempbitMap = BitmapFactory.decodeResource(getResources(), R.drawable.img); Bitmap bitmap = Bitmap.createScaledBitmap(tempbitMap,width,height, true); WallpaperManager wallpaperManager = WallpaperManager.getInstance(MainActivity.this); wallpaperManager.setWallpaperOffsetSteps(1, 1); wallpaperManager.suggestDesiredDimensions(width, height); try { wallpaperManager.setBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); } Also mention … Read more

Android – how to set the wallpaper image

If you have image URL then use WallpaperManager wpm = WallpaperManager.getInstance(context); InputStream ins = new URL(“absolute/path/of/image”).openStream(); wpm.setStream(ins); If you have image URI then use WallpaperManager wpm = WallpaperManager.getInstance(context); wpm.setResource(Uri.of.image); In your manifest file: <uses-permission android:name=”android.permission.SET_WALLPAPER”></uses-permission>

Change desktop wallpaper using code in .NET

Here’s a class yanked from an app I wrote a year or two ago: public sealed class Wallpaper { Wallpaper() { } const int SPI_SETDESKWALLPAPER = 20; const int SPIF_UPDATEINIFILE = 0x01; const int SPIF_SENDWININICHANGE = 0x02; [DllImport(“user32.dll”, CharSet = CharSet.Auto)] static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni); public enum Style … Read more

How to convert a Drawable to a Bitmap?

This piece of code helps. Bitmap icon = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon_resource); Here a version where the image gets downloaded. String name = c.getString(str_url); URL url_value = new URL(name); ImageView profile = (ImageView)v.findViewById(R.id.vdo_icon); if (profile != null) { Bitmap mIcon1 = BitmapFactory.decodeStream(url_value.openConnection().getInputStream()); profile.setImageBitmap(mIcon1); }