2

We are trying to set the downloaded image (and stored inside galley under our own folder) as wallpaper using our application, and its working using the below code.

public void Set_Current_wallpaper() {
    File f = new File(mCurrentWallpaperPath); // mCurrentWallpaperPath is Our folder inside gallery
    Uri contentUri = Uri.fromFile(f);
    Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setDataAndType(contentUri, "image/*");
    intent.putExtra("mimeType", "image/*");
    startActivity(intent);
}

Problem is right now when above code is running below is how set wallpaper application screen looks like, But if we directly open the image from gallery and set as wallpaper, this is the wallpaper set screen looks like. Why is it opening in different way? Attaching the screens Actual vs Expected here.

Actual Result

enter image description here

Expected Result

enter image description here

unitedartinc
  • 738
  • 1
  • 6
  • 25

1 Answers1

0

Have you tried WallpaperManager?

WallpaperManager wallpapermgr = WallpaperManager.getInstance(this);
wallpapermgr.setBitmap(yourbitmap);
Zamrony P. Juhara
  • 5,222
  • 2
  • 24
  • 40
  • Yes, But it will directly set the wallpaper without any option to move or place the image. – unitedartinc Jan 29 '16 at 02:55
  • @zamrony-p-juhara for suggestions or questions about the problem you can put it in a comment. – Michael Jan 29 '16 at 03:04
  • @michael, thank you but I need 50 reputations to put a comment on somebody's answer ;). – Zamrony P. Juhara Jan 29 '16 at 03:21
  • @ZamronyP.Juhara but posting questions as answers (or bad answers) won't earn you reputation. It might take a little extra work to make a good answer. Once you get to your 50 rep then you can comment. – Michael Jan 29 '16 at 03:24
  • @unitedartinc If you use WallpaperManager to set wallpaper, you must handle image cropping by yourself. I think that's why your Actual result looks different than expected result. Both applications (default wallpaper chooser and Gallery) handle their own wallpaper task differently. – Zamrony P. Juhara Jan 29 '16 at 03:39