How to set the phone wallpaper through an intent

1.7k views Asked by At

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.

1

There are 1 answers

5
Zulqurnain Jutt On

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);