gpt4 book ai didi

java - 如何使用位图将图像分享到社交媒体?

转载 作者:搜寻专家 更新时间:2023-11-01 07:50:05 25 4
gpt4 key购买 nike

我需要从我的 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com