我遇到了问题。在登录期间,我要求读取权限,这似乎工作正常,但每当我想分享的东西,我使用此方法来检查所需的权限:
public interface OnWritePermissionListener {
public void result(boolean success);
}
public void askWritePermissions(final OnWritePermissionListener listener) {
if (!getSession().getPermissions().containsAll(writePermissions)) {
L.d("Requesting write permissions.");
Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(activity, writePermissions);
newPermissionsRequest.setCallback(new StatusCallback() {
@Override
public void call(Session session, SessionState state, Exception exception) {
L.d("Status callback for askWritePermissions. State: %s. Exception: %s.", state.name(), exception == null ? "none" : exception.toString());
if (session.getPermissions().containsAll(writePermissions)) {
listener.result(true);
} else {
listener.result(false);
}
}
});
getSession().requestNewPublishPermissions(newPermissionsRequest);
} else {
L.d("Write permissions already granted.");
listener.result(true);
}
return;
}
writePermissions包含字符串条目:" publish_actions"
问题在于,当我调用此方法时,FB窗口只出现半秒钟然后消失,调用listener.result(false)。日志显示:
Status callback for askWritePermissions. State: OPENED_TOKEN_UPDATED. Exception: none.
任何想法我可能做错了什么?