Saturday, March 17, 2012

Android: Sharing Facebook, Twitter, E-mail

Okay, there are tutorials out there just as much as Justin Bieber that a little or a lot?? Anyway, here we gooo!!!

Sharing E-mail
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(android.content.Intent.EXTRA_SUBJECT, mTitle);
intent.putExtra(android.content.Intent.EXTRA_TEXT, mMessage);
startActivity(Intent.createChooser(intent, "Title of E-mail Chooser Dialog"));

Sharing Twitter
Use ""
You can append a string right after. So far appending this formats things correctly:

So your string looks like:

Sharing Facebook
Then most annoying sharing method if you plan to set a pre-made text in your app.

- Download the SDK and extract the folder you need (One with project files :\ )
- Create existing project with the Facebook stuff.
- Make sure it's a library. Go to Project Properties->Android, and check mark isLibrary
- Now add the library to your current project.
- Now you need to make a facebook activity. So create FacebookActivity!!!

- To create a preview message, implement it yourself. You can use a dialog or something. But you can directly post your message to your wall. Here's the code:

String response = facebook.request("me/feed", parameters, "POST");

- There's a lot more code in the activity, but you can just visit here:

Happy days!!!!

No comments:

Post a Comment