Monthly Archives: November 2010

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 :