Android - Share on Facebook, Twitter, Mail, ecc

Andrea Mario Lufino picture Andrea Mario Lufino · Jul 25, 2011 · Viewed 112.9k times · Source

I need to develop an app that has the share function. I have to share on Facebook, twitter, email and maybe other services.

How can I do this? There a library on the net? For the iOS development there were ShareKit, but for Android?

Thanks :)

Answer

Janusz picture Janusz · Jul 25, 2011

Paresh Mayani's answer is mostly correct. Simply use a Broadcast Intent to let the system and all the other apps choose in what way the content is going to be shared.

To share text use the following code:

String message = "Text I want to share.";
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("text/plain");
share.putExtra(Intent.EXTRA_TEXT, message);

startActivity(Intent.createChooser(share, "Title of the dialog the system will open"));