问题
I have successfully implemented login with facebook in android app. But now, Amazingly, When I do login one with facebook and if I try to login with facebook using facebook library 4.2.0 its onCancel() method is calling. Help!
回答1:
I solved this problem by calling: LoginManager.getInstance().logOut(); just before trying to login.
回答2:
i have not tried the above mentioned code but the thing worked for me is i have written some code in on cancel same as in success
@Override
public void onCancel() {
AccessToken token = AccessToken.getCurrentAccessToken();
if (token != null) {
GraphRequest request = GraphRequest.newMeRequest(
token,
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(
JSONObject object,
GraphResponse response) {
FBObject = response.getJSONObject();
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,email,gender, birthday");
request.setParameters(parameters);
request.executeAsync();
}
来源:https://stackoverflow.com/questions/31623847/facebookcallbackoncancel-is-calling-after-login-once-in-facebook-sdk-4-2-0-in