12

Possible Duplicate:
Android facebook/twitter share button

I am creating an app wherein i want to add share button , on clicking the button my app can be shared on facebook and twitter. Please let me know if anyone has a suitable answer which i can implement. Answers will be really appreciated.

Community
  • 1
  • 1
snn
  • 129
  • 1
  • 1
  • 4

3 Answers3

21
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/plain");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getResources().getString(R.string.recommendation_subject));
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, getResources().getString(R.string.recommendation_body));
startActivity(emailIntent);

Will prompt user to select appropriate application to perform action with (from installed on the phone)

Ram kiran Pachigolla
  • 20,897
  • 15
  • 57
  • 78
Konstantin Pribluda
  • 12,329
  • 1
  • 30
  • 35
  • 1
    The above code just sends an email(wherein i have to add a recipient). But how can i share my app directly to facebook/twitter??. Can you explain the above code? – snn Apr 06 '11 at 06:24
  • it just sends the intent, which is then picked up by application installed on phone - and user has the choice what application it would be. To see it in action look at: https://market.android.com/details?id=de.pribluda.games.android.lines&feature=more_from_developer (select menu->recommend) – Konstantin Pribluda Apr 06 '11 at 07:01
  • How to send a link of your application? – Ruchir Baronia Nov 19 '15 at 05:39
3

visit below link to post on fb

http://www.londatiga.net/it/how-to-use-facebook-sdk-to-post-status-from-android/

Punit Shah
  • 145
  • 1
  • 6
0

You are asking for code to post to facebook. Have you tried? Have you looked anywhere?

At least try, then post some code and we will help.

For Facebook, start with the Facebook SDK for Android. Here is the link the Graph API which allows you to interact with facebook.

Anthony Graglia
  • 5,355
  • 5
  • 46
  • 75