Share Button (Android)

//To implement a share button, we use Intent. An Intent provides a facility for performing late runtime binding between the code in different applications. //Just call this function shareFunction(); private void shareFunction() { //sharing implementation here Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Your Title"); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Your content will be shared "); startActivity(Intent.createChooser(sharingIntent, "Share via")); }
This snippet shows how to write function for Share button.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.