androidfacebookfacebook-graph-apishare-button

Disable Share button in Facebook SDK 4.0 on Logout


I implemented the sample hello facebook and I m confused on some points.

First when I test the app in real device from Android Studio, the post update button is already enabled (possibly) from facebook app which is already logged in

When I login normally by pressing my app's facebook login button, profile picture and name shows up. BUT why when I logout the Share button is still enabled?

private void updateUI() {

    boolean enableButtons = AccessToken.getCurrentAccessToken() != null;

    postStatusUpdateButton.setEnabled(enableButtons || canPresentShareDialog);


    Profile profile = Profile.getCurrentProfile();
    if (enableButtons && profile != null) {
        profilePictureView.setProfileId(profile.getId());
        greeting.setText(getString(R.string.hello_user, profile.getLastName()));
    } else {

Shall I put here postStatusUpdateButton.setEnabled(false);

        profilePictureView.setProfileId(null);
        greeting.setText(null);
    }
}

Solution

  • The Share button does not require the user to be logged in (via your app) in order to share. It will either switch to the Facebook app or pop up a webview. In either case, they can log into Facebook without having to log in via your app.

    That's why it's never disabled, even if there's no access token.