Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Share link on Facebook via android app with automatic parsing

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());
like image 336
John Ng Avatar asked Feb 28 '12 05:02

John Ng


2 Answers

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"));
like image 179
Sathyapradeep Avatar answered Sep 23 '22 06:09

Sathyapradeep


Finally, I got this to work. It turns out that the code I'm using above is working fine. The problem was that I was getting a facebook error due to incorrect hash key.

like image 20
John Ng Avatar answered Sep 23 '22 06:09

John Ng