我尝试在我的项目中实施谷歌登录,但是在使用gmail用户名和密码登录后,它给了我未知的主机错误。然后按下允许按钮。我还在构建提示中保留了android.playService.plus。是否还需要其他构建提示?我没有找到适当的文档或博客来应用它。我的代码如下:
if (googleLogin.isNativeLoginSupported()) {
if (!googleLogin.isUserLoggedIn()) {
googleLogin.doLogin();
}
AccessToken at = googleLogin.getAccessToken();
System.out.println("token " + at.getToken()); // this value is null
} else {
if (!googleLogin.isUserLoggedIn()) {
googleLogin.doLogin();
System.out.println("not logged in : not native login");
}
}
googleLogin.setCallback(new LoginCallback() {
@Override
public void loginFailed(String errorMessage) {
Dialog.show("Login Faild", "Retry Login", "Retry", null);
google_signIn(res);
}
@Override
public void loginSuccessful() {
System.out.println("successfull");
new NewForm(res).show();
}
});
错误:
Received exception: Unknown host
java.lang.Throwable: Unknown host
at javafx.scene.web.WebEngine$LoadWorker.describeError(WebEngine.java:1402)
at javafx.scene.web.WebEngine$LoadWorker.dispatchLoadEvent(WebEngine.java:1341)
at javafx.scene.web.WebEngine$LoadWorker.access$1100(WebEngine.java:1219)
at javafx.scene.web.WebEngine$PageLoadListener.dispatchLoadEvent(WebEngine.java:1206)
at com.sun.webkit.WebPage.fireLoadEvent(WebPage.java:2387)
at com.sun.webkit.WebPage.fwkFireLoadEvent(WebPage.java:2231)
at com.sun.webkit.network.URLLoader.twkDidFail(Native Method)
at com.sun.webkit.network.URLLoader.notifyDidFail(URLLoader.java:843)
at com.sun.webkit.network.URLLoader.lambda$didFail$93(URLLoader.java:826)
at com.sun.webkit.network.URLLoader$$Lambda$197/728465605.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$164(PlatformImpl.java:292)
at com.sun.javafx.application.PlatformImpl$$Lambda$63/2017575979.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(PlatformImpl.java:291)
at com.sun.javafx.application.PlatformImpl$$Lambda$62/1811810557.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$141(WinApplication.java:102)
at com.sun.glass.ui.win.WinApplication$$Lambda$54/5182121.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
答案 0 :(得分:0)
在模拟器上,我们需要使用Web登录,因为没有本机登录,并且它使用的网页可能看起来不太好。
在设备上使用本机登录并且应该感觉无缝。检查设备是否具有这种功能非常重要,因为它们的行为方式非常不同。