3

I want to share a message such as " Check out the image http://someUrl.com Shared from app ABCapp. The user must be able to choose any of the installed applications to share with. I am using the following code

Intent intent = new Intent(android.content.Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
        intent.putExtra(Intent.EXTRA_TEXT, shareMsg);
        startActivity(Intent.createChooser(intent,
                getString(R.string.share_using_application)));

It works fine for all other applications other than facebook. I have read some other questions which suggest to use facebook sdk. I am not very clear with what am I supposed to use fb sdk for? I want the list of applications to be shown on click of share option, after that am i supposed to take a different approach if user selects FB? Can the user's selection be detected? Please explain.

Jonik
  • 80,077
  • 70
  • 264
  • 372
user2041902
  • 593
  • 1
  • 6
  • 21
  • As you want to share a URL on FB and its not possible via intent to share link on facebook . That is why you have to use the FB SDK to share a link on FB with your whole text message. – GrIsHu Apr 10 '13 at 07:05
  • `"I want the list of applications to be shown on click of share option"` You can show the list of applications in spinner view if its limited i.e. email,twitter,facebook. – GrIsHu Apr 10 '13 at 07:08
  • @Grishu It would change from device to device as each device would have different set of installed applications how to get them into the list to be shown? – user2041902 Apr 10 '13 at 10:36

1 Answers1

1

You need to use Facebook Android SDK or Easy Facebook Android SDK to share.

EvZ
  • 11,889
  • 4
  • 38
  • 76
  • Thanks for replying I know that way it can be done but then you can't display all applications available in the device for sharing. Is there a way to detect and diverge from the intent chooser technique after the user chooses FB otherwise continue as it is. I guess that is not possible because its not handled by our app. If there is a way out please do tell – user2041902 Apr 10 '13 at 10:58
  • 3
    Actually [you *can* share a URL](http://stackoverflow.com/a/21189010/56285) without any SDKs, using only intents, but not any default text with it. – Jonik Jan 27 '14 at 12:49