Facebook Like Button In Android App?
There are a few other old SO questions asking a similar question, but there doesn't seem to be any definitive answer for them. Some time has passed since those questions were asked
Solution 1:
Well, I tried that a week ago. There is a "/like" graph method, which returns an error since it is not possible to like something from the SDK. So you have no choice but launching the website.
Solution 2:
The Like button can be used to like a Facebook Page or any Open Graph object and can be referenced by URL or ID. Here's what the code looks like. documentation android facebook sdk In your Activity or Fragment's onCreate method, use either the UiLifecycleHelper or call Settings.sdkInitialize:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
uiHelper = new UiLifecycleHelper(this, callback);
// if you don't want to use the UiLifecycleHelper, call sdkInitialize instead
// Settings.sdkInitialize(this);
...
Then set the object ID for the Like button (this can be a URL or a Facebook ID):
LikeView likeView = (LikeView) findViewById(R.id.like_view);
likeView.setObjectId("http://shareitexampleapp.parseapp.com/photo1/");
Lastly, call the UiLifecycleHelper again in your onActivityResult method
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
uiHelper.onActivityResult(requestCode, resultCode, data, null);
// if you don't use the UiLifecycleHelper, call handleOnActivityResult on the LikeView instead
// LikeView.handleOnActivityResult(this, requestCode, resultCode, data);
...
Post a Comment for "Facebook Like Button In Android App?"