Starting default Set as Wallpaper intent / activit

2019-07-23 11:42发布

问题:

I have a bitmap downloaded from a url and want to start android's default set as wallpaper intent/activity passing my bitmap. I have found following solution but missing value of "R.String.set_as" and "REQUEST_ID_SET_AS_WALLPAPER".

https://stackoverflow.com/a/26869604/4767525

what should be the value of this fields?

Thanks

回答1:

Don't really know about REQUEST_ID_SET_AS_WALLPAPER. I think it is related to the size of the image. R.String.set_as is just a string: "Set as:"

Use this code:

Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
                intent.setDataAndType(contentUri, "image/*");
                intent.putExtra("mimeType", "image/*");
                intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                startActivity(Intent.createChooser(
                        intent, "Set as:"));