Karim Lazaar
Karim Lazaar

Reputation: 1

Android share option

I have an application of favorite quotes made with flash CS5.5, I want to implement an option which can let the user share any quotes on Facebook, sms, etc..

(Similar to the share intent with java in eclipse)

How can I do that?

Upvotes: 0

Views: 501

Answers (2)

Daniel Handojo
Daniel Handojo

Reputation: 642

Ollie's answer is fine, I just want to clarify based on a post I've read + experience with this solution that posting to facebook DOES work, but likely only for links. Not text. It seems to ignore text altogether.

E.g. 'tis better to have loved and lost than to never have loved at all, www.rickrolls.com -> only the link shows up in the shared post. You can add the text in the facebook window, but the text doesn't carry over from the intent.

Upvotes: 0

Ollie C
Ollie C

Reputation: 28519

Sharing text to most apps (email, SMS, dropbox, etc) is easy:

private void share(String text, String windowTitle) {
    Intent share = new Intent(Intent.ACTION_SEND);
    share.setType("text/plain");
    share.putExtra(Intent.EXTRA_TEXT, text);
    startActivity(Intent.createChooser(share, windowTitle));
}

BUT, note this WILL NOT WORK WITH FACEBOOK as their app does not correctly respond to intents. They know about the problem, they clearly cannot be bothered to fix it.

So to implement sharing of text to the Facebook app, you'll need to use another approach, probably using their Android SDK. https://github.com/facebook/facebook-android-sdk

Upvotes: 2

Related Questions