0

I have some images saved on the phone internal storage in a filepath that looks like this:

/storage/emulated/0/myApp/FILENAME.jpg

I want to open an intent so that the user can set the phone wallpaper with his app of choice. Every code I tried doesn't work at all or only works with some apps. Thanks.

David
  • 11
  • 3

1 Answers1

2

You can set any image in sdcard or phone by opening this intent:

Intent intent = new Intent(Intent.ACTION_SET_WALLPAPER);
startActivity(Intent.createChooser(intent, "Select Wallpaper"));

kindly add permission too:

<uses-permission android:name="android.permission.SET_WALLPAPER"></uses-permission>

for more options check this answer

P.S: You need to add permission for SET_WALLPAPER for android 6+

Update:

You can also open set wallpaper as dialog using :

Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
intent.setDataAndType(imageUri, "image/*");
intent.putExtra("jpg", "image/*");
startActivityForResult(Intent.createChooser(intent,
getString(R.string.set_as)), REQUEST_ID_SET_AS_WALLPAPER);
Zulqurnain Jutt
  • 298
  • 3
  • 20
  • Hi, I don't want to use WallpaperManager, the wallpaper should be set for example through GooglePhotos or the phone's Launcher – David Sep 08 '17 at 12:21
  • You can no longer set wallpaper using [GooglePhotos](https://www.reddit.com/r/Nexus6P/comments/624vkl/can_no_longer_set_wallpaper_using_google_photos/) – Zulqurnain Jutt Sep 08 '17 at 12:55
  • yes I can, for example now i'm using QuickPic to set a wallpaper through Google Photos. I don't know how to do the same in my app. – David Sep 08 '17 at 13:04
  • Your code opens the intent dialog successfully but when I click on an app the app doesn't start. – David Sep 08 '17 at 14:03
  • I have found a solution – user11230 Sep 08 '17 at 14:18