Category Archives: Dev code

Code snippits for me

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.setType("text/plain");
 intent.putExtra(Intent.EXTRA_SUBJECT, subject);
 intent.putExtra(Intent.EXTRA_TEXT, text);
 
 startActivity(Intent.createChooser(intent, getString(R.string.share)));
}

thanks : http://labs.emich.be/2010/01/23/how-to-send-to-twitter-or-facebook-from-your-android-application/