Logo Questions Linux Laravel Mysql Ubuntu Git Menu

LikeView Callback

I am integrating Facebook LikeView in a fragment of Android App as defined in official fb docs.

LikeView like_button = (LikeView) findViewById(R.id.like_view);

I've also handled onActivityResult like this:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

uiHelper.onActivityResult(requestCode, resultCode, data, null);

I am unable to programmatically find if user have liked the page or unliked it from the LikeView. onActivityResults fires everytime the likeview's pop up returns but with no information about the result.

Please help me in identifying what am i missing. Any help will be greatly appreciated

like image 576
Amit Mittal Avatar asked Mar 18 '23 05:03

Amit Mittal

1 Answers

You can get the user's actions by adding this code to your onActivityResults:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            if (resultCode == RESULT_OK) {
                // verify we're returning from like action
                if ("com.facebook.platform.action.request.LIKE_DIALOG".equals(data.getStringExtra("com.facebook.platform.protocol.PROTOCOL_ACTION"))) {
                    // get action results
                    Bundle bundle = data.getExtras().getBundle("com.facebook.platform.protocol.RESULT_ARGS");
                    if (bundle != null) {
                        bundle.getBoolean("object_is_liked"); // liked/unliked
                        bundle.getInt("like_count"); // object like count
                        bundle.getString("completionGesture"); // liked/cancel/unliked
like image 82
Duda Avatar answered Mar 29 '23 04:03