4

I'm implementing a news application. I need to implement shared news links on gmail, twitter, or facebook etc. How can I do this?

Michael Petrotta
  • 59,888
  • 27
  • 145
  • 179
praveenb
  • 10,549
  • 14
  • 61
  • 83
  • [Here][1] is the same thing just to reassurance anyone who have doubts. [1]: http://stackoverflow.com/questions/6814268/android-share-on-facebook-twitter-mail-ecc – M090009 Apr 01 '13 at 04:27

2 Answers2

5

You can use an Intent with the Action SEND to share something. Android will look for every App on the phone that is able to receive this Intent and present a dialog to the user to choose from the Apps. In that way the user only gets the Services he uses. If he uses a Twitter Client that Client will react on a SEND intent, the mail application will react on it, the facebook app also and even something like MeinVZ a german social network will show up if the app is installed, even if you never thought of using this special Nework to share your news. To do this you just need to do something like this:

Intent share = new Intent(android.content.Intent.ACTION_SEND);
share.setType("text/plain");
share.putExtra(Intent.EXTRA_SUBJECT, "Name of the thing to share");
share.putExtra(Intent.EXTRA_TEXT, getText("Text that will be shared");
startActivity(Intent.createChooser(share, "Title of the dialog that will show up"));

For more information take a look at the links Konstantin provided

Janusz
  • 187,060
  • 113
  • 301
  • 369
2

Take a look here, here and here. It looks like you need ACTION_SEND intent.

Community
  • 1
  • 1
Konstantin Burov
  • 68,980
  • 16
  • 115
  • 93