Reputation: 5665
I'm trying to share an image with an intent to social media. It's asking for the path to the image, and I've retrieved the image URL from my object, in the form of files.parsetfss.com/77c6003f-0d1b-4b55-b09c-16337b3a2eb8/tfss-7267d2df-9807-4dc0-ad6f-0fd47d83d20f-3eb7b9e4-d770-420c-a0a0-9ca4fc4a6a0a_1.png
, for example. The share intent displays but when I open any other app to share, I get a crash with no logcat error. What could be going wrong?
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/*");
share.putExtra(Intent.EXTRA_STREAM, marketFeedItem.getDesign().getImage());
startActivity(Intent.createChooser(share, "Share your design!"));
Updated Answer. This is what I did to get it to work:
ImageView imageView = (ImageView) feedItemView.findViewById(R.id.image);
Drawable mDrawable = imageView.getDrawable();
Bitmap mBitmap = ((BitmapDrawable)mDrawable).getBitmap();
String path = MediaStore.Images.Media.insertImage(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!");
startActivity(Intent.createChooser(share, "Share Your Design!"));
Upvotes: 1
Views: 1330
Reputation: 676
URL of your parse server for the image file is not a valid for share intent, so save loaded bitmap temporary in your device then share image using that saved bitmap URL. After image shared you can delete saved image from your device
Upvotes: 1
Reputation: 1006614
If getImage()
is returning the long string that you have in your question, that is not a valid URL, as it lacks a scheme.
According to the docs, you need to pass a content:
Uri
in the EXTRA_STREAM
extra. In practice, a file:
Uri
frequently also works. I would expect you to run into problems with other schemes, like https:
or http:
.
Upvotes: 2