Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

share image with URL android share intent

I need to know if it is possible to share an image using only its url with a share intent. Here is my code.

Intent imageIntent = new Intent(Intent.ACTION_SEND);
Uri imageUri = Uri.parse("http://eofdreams.com/data_images/dreams/face/face-03.jpg");
imageIntent.setType("image/*");
imageIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
startActivity(imageIntent);

So far its not working and I haven't found any helpful answers online. I would like to do this using the share intent and without downloading the image.

like image 394
Amanni Avatar asked Aug 05 '14 09:08

Amanni


People also ask

What is the use of intent createChooser () method?

Most commonly, ACTION_SEND action sends URL of build-in Browser app. While sharing the data, Intent call createChooser() method which takes Intent object and specify the title of the chooser dialog. Intent. createChooser() method allows to display the chooser.


1 Answers

You can share image using share intent, but you've to decode image to a localized Bitmap

Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, "Hey view/download this image");
String path = Images.Media.insertImage(getContentResolver(), loadedImage, "", null);
Uri screenshotUri = Uri.parse(path);

intent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
intent.setType("image/*");
startActivity(Intent.createChooser(intent, "Share image via..."));

loadedImage is the loaded bitmap from http://eofdreams.com/data_images/dreams/face/face-03.jpg

like image 75
Nitin Misra Avatar answered Nov 13 '22 02:11

Nitin Misra