我需要从我的 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!"));
}
});
最佳答案
试试
share.setType("image/*");
关于java - 如何使用位图将图像分享到社交媒体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35966487/