1
Facebookのサインインを実装しました。これは正常にサインインしますが、アプリを再起動すると、再度ログインする必要があります。しかし、私がFBでログインしている場合は、そうする必要があります。 は、ここに私のAuthListener
です:AndroidアプリFacebook Sign-Inはユーザーを覚えていますが、Google Sign Inはありません
mAuthListener = new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null) {
Log.d("AD", "User is logged in.");
SignUp.this.startActivity(startMainActivity);
} else {
Log.d("AD", "User is not logged in.");
}
}
};
とGoogleのログインを行うには他のすべて:
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this /* FragmentActivity */, new GoogleApiClient.OnConnectionFailedListener() {
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
Toast.makeText(SignUp.this, "There has been an error connecting to Google: " + connectionResult.getErrorMessage(), Toast.LENGTH_LONG).show();
}
} /* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
SignInButton signInButton = (SignInButton) findViewById(R.id.sign_in_button);
signInButton.setOnClickListener(this);
private void signIn() {
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, RC_SIGN_IN);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
mCallbackManager.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
handleSignInResult(result);
}
private void handleSignInResult(GoogleSignInResult result) {
Log.d("AD", "Signed in via google successfully:" + result.isSuccess());
if (result.isSuccess()) {
// Signed in successfully, show authenticated UI.
this.startActivity(startMainActivity);
} else {
// Signed out, show unauthenticated UI.
Toast.makeText(this, "An error has occurred", Toast.LENGTH_SHORT).show();
}
}
これは変です。私はいつもGoogleと何の問題もありません:{