Share link on Facebook via android app with automatic parsing

John Ng picture John Ng · Feb 28, 2012 · Viewed 10.7k times · Source

When posting a link on Facebook, the link to an article is automatically parsed, displays the link, article title, short description, and a thumbnail.

I want to do the same thing, but from my android app. I have set up the Facebook SDK already and the log in feature and request for permission is already working fine. However, I don't know how to proceed with sharing a link on Facebook, and automatically let Facebook handle the parsing.

I also want to display the Facebook post dialog, so that the user can add a personal message with the shared link. Right now, I'm using the dialog method of Facebook but it doesn't work. It doesn't even display the dialog box. Any ideas?

Bundle parameters = new Bundle();
parameters.putString("link", link);
// post on user's wall.
facebook.dialog(context, "feed", parameters, new PostDialogListener());

Answer

Sathyapradeep picture Sathyapradeep · Feb 28, 2012

add the below code where you need to share your link

intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(android.content.Intent.EXTRA_TEXT,"https://Your Link");
intent.putExtra(android.content.Intent.EXTRA_STREAM,R.drawable.icon);
startActivity(Intent.createChooser(intent, "Your Chooser Title"));