I want to ask a user of my Android application to allow sharing on facebook when the user access button is clicked (this is just an ImageView). On the OnClick method button, I execute this block:
CallbackManager facebookCallbackManager; ... facebookCallbackManager = CallbackManager.Factory.create(); LoginManager.getInstance().registerCallback(facebookCallbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { shareContent(activity, content, true); } @Override public void onCancel() { } @Override public void onError(FacebookException error) { } }); LoginManager.getInstance().logInWithPublishPermissions(activity, Collections.singletonList("publish_actions"));
And then I redefine:
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); facebookCallbackManager.onActivityResult(requestCode, resultCode, data); }
The problem is that the request never arrives: the perpetual wheel of the rotator is displayed, and callbacks are not called (and also are not deleted, are not canceled and no error occurs).
a. The user is already logged in, according to:
public static boolean isLoggedIn() { AccessToken accessToken = AccessToken.getCurrentAccessToken(); return accessToken != null; }
b. FacebookSdk.isInitialized() true
with. The publication of permits is not granted, in accordance with:
private static boolean hasPublishPermissions() { AccessToken accessToken = AccessToken.getCurrentAccessToken(); return accessToken != null && accessToken.getPermissions().contains("publish_actions"); }
e. Other FB SDK applications are used through the application and they function.
e. I am the application administrator in the FB control panel
Any idea on a problem?
Important PS:
Since the Facebook API is extremely stable, depending on the time of day or the position of the stars, without changing the code I have three possible results :
- As described above, an ever-rotating wheel.
- The callback invokes the
onCancel method without user interaction. He shares content without asking for confirmation - this gave me a pleasant unwanted video posted on my personal FB, noticing me without :):
PS2: Even the classic LoginManager.getInstance().logInWithReadPermission now has the same problem. This was not the case before.