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!")); 
      } 
     }); 

回答

4

尝试

share.setType("image/*"); 
+0

神奇。哇。这让我的脑子有一段时间了。哈哈。我会在9分钟内接受答案。/*帐户是否有不同的图片扩展名?准确地说是 – santafebound

+1

。你可以定义特定类型,如'png','gif'等。 –