我有以下代码,其中使用“设置墙纸”按钮创建了一个对话框。我已经将图像设置为bitmap
,问题是如何通过意图设置墙纸?
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setSmallIcon(R.drawable.ic_image_black_24dp).setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.logo_2))
.addAction(R.drawable.ic_wallpaper_black_24dp, "Set as wallpaper", //WHAT GOES HERE)
.setContentTitle("Saved screenshot")
.setStyle(new NotificationCompat.BigPictureStyle().bigPicture(bitmap));
0个关于意图,未决意图的知识,而不是什么。
答案 0 :(得分:0)
尝试使用此代码,但必须手动选择设置为墙纸选项
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_ATTACH_DATA);
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.background);
shareIntent.putExtra(Intent.EXTRA_STREAM, bitmap);
shareIntent.setType("image/jpeg");
startActivity(shareIntent);