Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Share on Facebook, Twitter, Mail, ecc

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 :)

like image 929
Andrea Mario Lufino Avatar asked Jul 25 '11 09:07

Andrea Mario Lufino


1 Answers

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")); 
like image 196
Janusz Avatar answered Sep 23 '22 07:09

Janusz