Skip to content

Instantly share code, notes, and snippets.

@dlfinis
Created December 20, 2014 19:43
Show Gist options
  • Save dlfinis/2fedcf1f1bd1737a3ef0 to your computer and use it in GitHub Desktop.
Save dlfinis/2fedcf1f1bd1737a3ef0 to your computer and use it in GitHub Desktop.
Button Listener to share content with other App
private View.OnClickListener btnShare_onClickListener= new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent textShareIntent = new Intent(Intent.ACTION_SEND);
textShareIntent.putExtra(Intent.EXTRA_TEXT,getString(R.string.message_share));
textShareIntent.setType("text/plain");
//startActivity(textShareIntent);
// ^^ this auto-picks the defined default program for a content type, but since we want users to
// have options, we instead use the OS to create a chooser for users to pick from
startActivity(Intent.createChooser(textShareIntent, getString(R.string.title_share)));
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment