Share text and URL on Facebook
Asked Answered
D

1

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.

Diploid answered 10/4, 2013 at 6:53 Comment(3)
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.Cleome
"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.Cleome
@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?Diploid
I
1

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

Interactive answered 10/4, 2013 at 7:35 Comment(2)
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 tellDiploid
Actually you can share a URL without any SDKs, using only intents, but not any default text with it.Eleonoreleonora

© 2022 - 2024 — McMap. All rights reserved.