2
我需要從我的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!"));
}
});
神奇。哇。這讓我的腦子有一段時間了。哈哈。我會在9分鐘內接受答案。/*帳戶是否有不同的圖片擴展名?準確地說是 – santafebound
。你可以定義特定類型,如'png','gif'等。 –