Search code examples
androidandroid-intentwallpaper

How to start the "set as" intent (wallpaper, contact picture, etc)


I searched over the web during the last few weeks (seriously) but I can't find what I need. I just would like to start an intent corresponding to the set as action. It generally offers either Set as wallpaper or Set as contact picture. And then, if more application are installed on the device, they can be listed as well.

Here is an example of what I want :

enter image description here

I precise that I need to support API level 14 and higher. I found getCropAndSetWallpaperIntent but it works only with content URI which is a problem for me, and is only availbable on API lvl 19 and higher.


Solution

  • I found the answer by my self :

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

    You just have to ensure that the uri is public and will be reachable by the crop application chosen by the user.