我正在尝试使用Firebase登录到Facebook,然后获取姓名,电子邮件,个人资料图片。
一切正常,直到单击登录按钮,然后弹出Facebook帐户窗口。之后,当我通过单击“继续使用xxxxxx”选择一个帐户,并且<应用程序已停止>时。
当我重新启动我的应用程序时,我发现身份验证已完成,没有错误
任何帮助将不胜感激。
这是我的authfacebook.java:
facebook.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
LoginManager.getInstance().logInWithReadPermissions(PhoneAuthActivity.this, Arrays.asList("email", "public_profile"));
LoginManager.getInstance().registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
Log.d(TAG, "facebook:onSuccess:" + loginResult);
handleFacebookAccessToken(loginResult.getAccessToken());
Toast.makeText(PhoneAuthActivity.this, "success", Toast.LENGTH_SHORT).show();
finish();
startActivity(new Intent(PhoneAuthActivity.this, nav_activity.class));
}
@Override
public void onCancel() {
Log.d(TAG, "facebook:onCancel");
Toast.makeText(PhoneAuthActivity.this, "cancel", Toast.LENGTH_SHORT).show();
}
@Override
public void onError(FacebookException error) {
Log.d(TAG, "facebook:onError", error);
Toast.makeText(PhoneAuthActivity.this, error.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
});
private void handleFacebookAccessToken(AccessToken token) {
netCheckin();
Log.d(TAG, "handleFacebookAccessToken:" + token);
progressDialog = ProgressDialog.show(this, "Loading...", "Please wait Posts is Loading...");
AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());
mAuth.signInWithCredential(credential).addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
//Sign in success, update UI with the signed-in user's information
Log.d(TAG, "signInWithCredential:success");
progressDialog.dismiss();
mAuth.addAuthStateListener(mAuthListener);
} else {
// If sign in fails, display a message to the user.
Log.w(TAG, "signInWithCredential:failure", task.getException());
Toast.makeText(PhoneAuthActivity.this, "Authentication failed. Please Use another Account.", Toast.LENGTH_SHORT).show();
progressDialog.dismiss();
}
// ... }
}
});
}