0

I need to add a share button to one view inside one of my DialogFragments (Not in the action bar).

Can you give me a clue or a sample maybe? All I could find googling is for action bar (like Sherlok) which is not what I'm looking for.

Fatima
  • 869
  • 10
  • 35

1 Answers1

2

Step #1: Put a button inside of your DialogFragment.

Step #2: When the user clicks the button, create an ACTION_SEND Intent to share whatever it is you want to share, and call startActivity() on it (or, if desired, wrap the Intent you create in a chooser Intent via Intent.createChooser()):

  void sendIt(String theMessage) {
    Intent i=new Intent(Intent.ACTION_SEND);

    i.setType("text/plain");
    i.putExtra(Intent.EXTRA_SUBJECT, R.string.share_subject);
    i.putExtra(Intent.EXTRA_TEXT, theMessage);

    startActivity(Intent.createChooser(i,
                                       getString(R.string.share_title)));
  }
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491