Android Android SDK is automatically registered

I am using the following facebook-sdk version:

com.facebook.android:facebook-android-sdk:4.+

      

I am using the default facebook login button to view the login

<com.facebook.login.widget.LoginButton
    android:id="@+id/login_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="85dp" />`

      

With the following Java code

 LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList(permissions));
 LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
       //details intentionally hidden
 }

      

But to log out I am using a custom button where on click I do the following

LoginManager.getInstance().logOut();
AccessToken.setCurrentAccessToken(null);

      

But the Facebook login button registers without clicking! It just loops continuously!

What should I do?

+3


source to share


1 answer


You need to register the callback with LoginButton

so that it only rings when a button is pressed.

use below code: OnCreate()



 loginButton = (LoginButton) findViewById(R.id.login_button);
 List<String> permissionNeeds = Arrays.asList( "public_profile", "email", "user_birthday", "user_friends");
loginButton.setReadPermissions(permissionNeeds);

loginButton.registerCallback(callbackManager,
        new FacebookCallback<LoginResult>() {

         @Override
            public void onSuccess(LoginResult loginResult) { and so on }

      

+2


source







All Articles