I\'m trying to add an image to my twitter share intent. I save an image locally in one class and then in another I get the image and try to attach to my intent.
Here is
Here is solution:
private fun shareOnTwitter() {
val file = File(context!!.filesDir, FILENAME_SHARE_ON_TWITTER)
val uriForFile = FileProvider.getUriForFile(context!!, com.yourpackage.activity.YourActivity, file)
val intent = Intent(Intent.ACTION_SEND).apply {
type = "image/jpeg"
putExtra(Intent.EXTRA_STREAM, uriForFile)
}
startActivity(intent)
}