我需要从我的RecyclerAdapter共享图像,因为图像最初不存在,即在使用适配器的Activity中加载。如何将位图分享给社交媒体?每次我点击在我的应用程序中共享它都会显示"没有应用程序可以执行此操作"。
feedItemView.setFeedSocialShareClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Share to Social Media
ImageView imageView = (ImageView) feedItemView.findViewById(R.id.image);
Drawable mDrawable = imageView.getDrawable();
Bitmap mBitmap = ((BitmapDrawable)mDrawable).getBitmap();
String path = MediaStore.Images.Media.insertImage(context.getContentResolver(),
mBitmap, "Design", null);
Uri uri = Uri.parse(path);
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image");
share.putExtra(Intent.EXTRA_STREAM, uri);
share.putExtra(Intent.EXTRA_TEXT, "I found something cool!");
context.startActivity(Intent.createChooser(share, "Share Your Design!"));
}
});
答案 0 :(得分:4)
尝试
share.setType("image/*");