Skip to content

Instantly share code, notes, and snippets.

@ahmedbr
Created September 30, 2018 20:38
Show Gist options
  • Save ahmedbr/ee705a4b04c36f2115879d9b01de50ae to your computer and use it in GitHub Desktop.
Save ahmedbr/ee705a4b04c36f2115879d9b01de50ae to your computer and use it in GitHub Desktop.
This gist is for activating share button in your android application.
// add the following code to your button:
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
String shareBody = "Here is the share content body";
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject Here");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
startActivity(Intent.createChooser(sharingIntent, "Share via"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment