Android Facebook SDK v4 Viewing Problem

I am trying to implement Facebook "Like Button" in my Android app. Before I used the Facebook SDK v3, where you set up LikeView, then call likeView.handleOnActivityResult (context, requestCode, resultCode, data) inside onActivityResult (); This would change the button so that after the page was “liked”, it would show “Liked” and the number of people who also like the page.

Now I use the Facebook SDK v4 because v3 is now deprecated. In this version, I do not see any documentation or do not have the same type of functionality for the like button. It no longer has the likeView.handlePnActivityResult method that v3 had. Now, when the user clicks the “how” button and loves the page, it does not change the state of the button.

Does anyone know how to solve this problem so that it has the same features as LikeView in the Facebook SDK v3?

Here is the code of what I am doing:

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Initialize FaceBook SDK FacebookSdk.sdkInitialize(this); setContentView(R.layout.activity_about); // Set up ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); terms = (LinearLayout) findViewById(R.id.terms_holder); privacyPolicy = (LinearLayout) findViewById(R.id.privacy_policy_holder); share = (LinearLayout) findViewById(R.id.social_media_holder); environmentButton = (Button) findViewById(R.id.environment_change); likeView = (LikeView) findViewById(R.id.like_view); likeView.setObjectIdAndType("##############", LikeView.ObjectType.PAGE); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); // In the old Facebook SDK this is where it would change the like button to "liked 2,038" but this code is deprecated now apparently // likeView.handleOnActivityResult(this, requestCode, resultCode, data); } 

And here is my XML:

 <LinearLayout android:id="@+id/social_media_holder" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:paddingBottom="10dp" android:gravity="center_vertical" android:clickable="true" android:onClick="onClick" > <com.facebook.share.widget.LikeView android:id="@+id/like_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="10dp" /> <TextView android:id="@+id/post_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="5dp" android:text="@string/post_about_us" android:textSize="20dp" android:textColor="@color/dark_grey" /> 

+8
android facebook sdk
source share
2 answers

Guardanis answer is correct (question comments section). But this is the code for it (I used).

in onCreate (...)

 callbackManager = CallbackManager.Factory.create(); 

in onActivityResult (...)

  callbackManager.onActivityResult(requestCode, resultCode, data); 
+6
source share

Native Like Button: Native Like Button, designed for mobile applications, will no longer be supported starting with SDK version 4.28 and higher. Previous versions of the SDK may still use the Native Like Button, but starting with 2/6, the Native Like Button will no longer be supported. After 2/6, the dialogs for Native Like will no longer be displayed, and clicking on any native button will not lead to action.

0
source share

All Articles