Sharing image url to Other installed apps in mobile Android

There will be lots of answer you will find in SO. Few answers will work and few will not .To download image from url we need to build URI from the downloaded file.

If you are using Glide to load image from url, then it can be done in following way:

.into(object: CustomTarget<Bitmap>() {

override fun onLoadCleared(placeholder: Drawable?) {
// do your stuff, you can load placeholder image here

override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {

val cachePath = File(context.cacheDir, "images")
cachePath.mkdirs() // don't forget to make the directory
val stream = FileOutputStream(cachePath.toString() + "/image.png") // overwrites this image every time
resource.compress(Bitmap.CompressFormat.PNG, 100, stream)

val imagePath = File(context.cacheDir, "images")
val newFile = File(imagePath, "image.png")
val contentUri: Uri = FileProvider.getUriForFile(context, "${BuildConfig.APPLICATION_ID}.provider", newFile)

val intent = Intent(Intent.ACTION_SEND)
intent.type = "image/*"
intent.putExtra(Intent.EXTRA_STREAM, contentUri)
context.startActivity(Intent.createChooser(intent, "Choose..."))


add provider in manifest:

android:resource="@xml/provider_paths" />

make a new resource file called xml in res . In res create a new file called provider_paths: — —

<paths xmlns:android="">
<cache-path name="cache" path="/" />

Then you are done :) — -



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store