看起来最近的CN1更新破坏了Android上的Facebook登录功能
这一切都在最近才起作用,但我们的测试人员注意到它在最新版本中被破坏了
代码基于此示例:
https://www.codenameone.com/facebook-login.html
我的代码如下:
Log.p("about to try and connect to facebook with SDK");
Login fb = FacebookConnect.getInstance();
fb.setClientId(clientId);
fb.setRedirectURI(redirectURI + "/");
fb.setClientSecret(clientSecret);
fb.setCallback(new LoginCallback() {
@Override
public void loginSuccessful() {
Log.p("facebook login complete");
fbLoginComplete(callback, createNew, fb.getAccessToken().getToken());
}
@Override
public void loginFailed(String errorMessage) {
Log.p("facebook login error: " + errorMessage);
callback.failed("There was an error connecting to Facebook");
}
});
if (!fb.isUserLoggedIn()) {
Log.p("doing login");
fb.doLogin();
} else {
Log.p("already logged in");
fbLoginComplete(callback, createNew, fb.getAccessToken().getToken());
}
Android上没有触发loginSuccessful()和loginFailed()。它适用于iOS和模拟器。