+ // Add a Share Image entry.
+ contextMenu.add(R.string.share_image).setOnMenuItemClickListener {
+ // Create the share intent.
+ val shareUrlIntent = Intent(Intent.ACTION_SEND)
+
+ // Add the URL to the intent.
+ shareUrlIntent.putExtra(Intent.EXTRA_TEXT, imageUrl)
+
+ // Set the MIME type.
+ shareUrlIntent.type = "text/plain"
+
+ // Set the intent to open in a new task.
+ shareUrlIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+
+ //Make it so.
+ startActivity(Intent.createChooser(shareUrlIntent, getString(R.string.share_url)))
+
+ // Consume the event.
+ true
+ }
+