It’s an example of what Intents are all about in Android, but today was the first time I’ve used the android.content.Intent.ACTION_SEND action to allow users to send emails, post to Twitter or Facebook, send text messages, etc! It couldn’t be any easier, here’s the code:
Java
Intent myIntent = new Intent(android.content.Intent.ACTION_SEND);
myIntent.setType("text/plain");
myIntent.putExtra(Intent.EXTRA_SUBJECT, "My Subject Line");
myIntent.putExtra(Intent.EXTRA_TEXT, "My Message!");
startActivity(Intent.createChooser(myIntent, "Choose app"));
That’s it! Any applications that the user has installed that can handle the ACTION_SEND intent will be listed in a nice system popup window. On my Droid I see Facebook, Gmail, Messaging (text messages), and Twitter.
Enjoy…