我在我的Android应用中使用firebaseUI android library。登录UI在MainActivity的应用程序上启动。 MainActivity onCreate()方法将检查登录是否已经完成。如果没有,它将显示从firebaseUI库启动的登录屏幕。
现在,如果用户关闭了互联网并在登录屏幕上并尝试使用"使用Google登录"按钮,将出现选择谷歌帐户的弹出窗口。用户可以选择一个帐户,库可以显示进度条。由于互联网不存在,登录失败,但登录屏幕上没有相同的指示。
logcat显示错误为
E/CredentialSignInHandler: Unexpected exception when signing in with credential
com.google.firebase.FirebaseNetworkException: A network error (such as timeout, interrupted connection or unreachable host) has occurred.
如何在我的应用中处理此问题并向用户显示有关连接到互联网的通知?
答案 0 :(得分:0)
我的建议是检查您的GoogleService-Info.plist
我认为这可能会对你有所帮助
答案 1 :(得分:0)
你需要修改onConnectionFailed,请参阅下面的代码以供参考。
Google登录的代码主要是来自
的锅炉版 public void onSignInGooglePressed(View view) {
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, RC_GOOGLE_LOGIN);
ProgressDialog.show();
}
@Override
public void onConnectionFailed(ConnectionResult result) {
/**
* An unresolvable error has occurred and Google APIs (including
* Sign-In) will not
* be available.
*/
ProgressDialog.dismiss();
Toast.makeText(LoginActivity.this,result.toString(),Toast.LENGTH_SHORT).show();
}