本文介绍了如何使用位图将图像分享到社交媒体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从RecyclerAdapter共享一个图像,因为该图像最初并不存在,即是在使用适配器的Activity中加载的。如何将位图共享到社交媒体?每次我在应用程序中单击共享时,都会显示没有应用程序可以执行此操作。

I need to share an image from my RecyclerAdapter because the image does not initially exist, i.e. is loaded within the Activity making use of the adapter. How can I share the bitmap to social media? Every time I click share in my app it says "No apps can perform this action".

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/*");

这篇关于如何使用位图将图像分享到社交媒体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-16 20:56