How to share image to social media with bitmap?

浪子不回头ぞ 提交于 2020-01-02 16:01:44

问题


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

回答1:


try with

 share.setType("image/*");


来源:https://stackoverflow.com/questions/35966487/how-to-share-image-to-social-media-with-bitmap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!