How to send to Twitter or Facebook from your Android application

use the intent action ACTION_SEND together with an IntentChooser. This way the user can choose whatever application that can receive the ACTION_SEND intent: email, Twitter, Facebook, Text. this function takes as a parameter the subject and text. You could add the context to the parameters and make the method static in a utility class, for example.

public void share(String subject,String text) {
 final Intent intent = new Intent(Intent.ACTION_SEND);
 intent.putExtra(Intent.EXTRA_SUBJECT, subject);
 intent.putExtra(Intent.EXTRA_TEXT, text);
 startActivity(Intent.createChooser(intent, getString(R.string.share)));

thanks :

About Brett

I live in Jacksonville, Florida USA where I ride my bike and run a small PC and network repair biz. I consider my self extremely lucky to earn a living doing what I love. I have been earning my living in this way for several years. Alas, my personality doesn’t allow me to rest on the successes of my past. Entrepreneurs are cursed that way. I started SpyandSeek while still in college but never finished it. (slight ADD another curse.) After a two years in the PC trade I decided it was time to finish what I started and so SpyandSeek was born. SpyandSeek has analyzed thousands of HijackThis logs from around the world since it’s launch in late 2005. It still amazes me how a tiny site like mine can touch so many far off places.