Share image with urls

I need to know if it is possible to share an image using only its URL with the intention to share. 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); 

While it does not work, and I have not found useful answers on the Internet. I would like to do this using the sharing intent and without uploading the image.

+7
android android-intent
source share
4 answers

You can share images using the sharing intent, but you must decode the image into 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 - the loaded bitmap from http://eofdreams.com/data_images/dreams/face/face-03.jpg

+15
source share

See here HERE

 final ImageView imgview= (ImageView)findViewById(R.id.feedImage1); Uri bmpUri = getLocalBitmapUri(imgview); if (bmpUri != null) { // Construct a ShareIntent with link to image Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, bmpUri); shareIntent.setType("image/*"); // Launch sharing dialog for image startActivity(Intent.createChooser(shareIntent, "Share Image")); } else { // ...sharing failed, handle error } 

then add this to your activity:

 public Uri getLocalBitmapUri(ImageView imageView) { // Extract Bitmap from ImageView drawable Drawable drawable = imageView.getDrawable(); Bitmap bmp = null; if (drawable instanceof BitmapDrawable){ bmp = ((BitmapDrawable) imageView.getDrawable()).getBitmap(); } else { return null; } // Store image to default external storage directory Uri bmpUri = null; try { File file = new File(Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_DOWNLOADS), "share_image_" + System.currentTimeMillis() + ".png"); file.getParentFile().mkdirs(); FileOutputStream out = new FileOutputStream(file); bmp.compress(Bitmap.CompressFormat.PNG, 90, out); out.close(); bmpUri = Uri.fromFile(file); } catch (IOException e) { e.printStackTrace(); } return bmpUri; } 
+1
source share

convert url to string format

 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, String.valueOf(imageUri)); startActivity(imageIntent); 
-one
source share
 Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT,"http://eofdreams.com/data_images/dreams/face/face-03.jpg"); startActivity(Intent.createChooser(intent, "Share Image")); 
-one
source share

All Articles