My application shows a picture and then set it as wallpaper device.
I have code and already try it on some devices and running successfully. (Lenovo Vibe C Lolipop, Advan I7 Marshmallow)
But I found a problem on device Xiaomi Redmmi 5 (Nougat)
When I set picture as wallpaper by intent chooser, there was no "Gallery" option
Note: I think on Xiaomi, Gallery Option is best choice to set picture as a device wallpaper than others
I attached screenshoot of Lenovo Vibe C (have Gallery option) and Xiaomi Redmi 5 (No gallery option)
Below is my code snippet
//I have picture in "Wallpaper Folder", its name is "IMG_Wallpaper.jpg"
File folderPict = new File(Environment.getExternalStorageDirectory() + File.separator + "Wallpaper Folder");
String pictName = "IMG_Wallpaper.jpg";
String destFileName = folderPict.getAbsolutePath() + "/" + pictName;
filePict = new File(destFileName);
// In this step, I already have filePict "IMG_Wallpaper.jpg" in folder "folderPict"
//get uri from external file
Uri uriPict = Uri.fromFile(filePict);
//set wallpaper by intent chooser
Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
intent.setDataAndType(uriPict, "image/*");
intent.putExtra("mimeType", "image/*");
startActivity(Intent.createChooser(intent, "Set as"));