Android - Firebase动态Facebook按钮 [英] Android - Firebase Dynamic Facebook button
问题描述
我想用Facebook登录按钮来登录我的应用程序。
<现在,当点击
loginbutton
时,我登录并继续第二个活动。 callbackManager = CallbackManager.Factory.create();
LoginButton loginButton =(LoginButton)findViewById(R.id.loginButton);
loginButton.setReadPermissions(email,public_profile);
loginButton.registerCallback(callbackManager,new FacebookCallback< LoginResult>(){
@Override
public void onSuccess(LoginResult loginResult){
Log.d(TAG,facebook:onSuccess :+ loginResult);
handleFacebookAccessToken(loginResult.getAccessToken());
}
@Override
public void onCancel(){
Log。 d(TAG,facebook:onCancel);
// ...
}
@Override
public void onError(FacebookException错误){
Log.d(TAG,facebook:onError,错误);
// ...
}
});
现在在第二项活动中,我有一个按钮 Sign Out 我到第一个活动,并签署我登录我的帐户。代码:
AuthUI.getInstance()
.signOut(this)
.addOnCompleteListener(new OnCompleteListener< ();
@Override
public void onComplete(@NonNull Task< Void> task){
finish();
}
});
现在,一切正常,除了退出部分。
它注销帐户(我可以在我的日志中看到它)。但是当我回到MainActivity时,动态的Facebook登录按钮仍然表示: 这是我使用的Facebook按钮: 我已经使用了这个,但是找不到任何东西。 但是没有任何不同的结果。 我也有同样的不好的经验。最后,我使用 Excuse me for double posting this question, I did not get a response and I still have the same problem. Tried to fix it, but wasn't successful. Any help is greatly appreciated. I want to use the Facebook login button to sign users in to my app. Now when the Now in the 2nd activity, I have a button Sign Out which returns me to the 1st activity, and sign out my account I signed in with. Code: Now, everything works fine, except for the sign out part. It does sign out the account (I can see it in my log). But when I get back to the MainActivity, the dynamic Facebook login button still says: This is the Facebook button I use: I have googled this, but I could not find anything.
Tried to change the sign out method to But this was without any different result. I had the same bad experience with that. Finally, I use the
这篇关于Android - Firebase动态Facebook按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!退出
,而应该已经说用Facebook登录$
< com.facebook.login.widget.LoginButton
android:id =@ + id / loginButton
android:layout_width =match_parent
android:layout_height =match_parent
android:layout_gravity =center_horizontal
android:layout_weight =1
android:layout_marginBottom =56dp
android:layout_alignParentBottom =true
android: layout_alignParentStart =true/>
尝试将注销方法更改为
FirebaseAuth.getInstance()。signOut();
LoginManager
进行Facebook身份验证,并做了如下操作:
public void logOut(){
FirebaseAuth.getInstance()。signOut();
LoginManager.getInstance()。logOut();
}
loginbutton
is clicked, I log in and continue to the 2nd activity.callbackManager = CallbackManager.Factory.create();
LoginButton loginButton = (LoginButton) findViewById(R.id.loginButton);
loginButton.setReadPermissions("email", "public_profile");
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
Log.d(TAG, "facebook:onSuccess:" + loginResult);
handleFacebookAccessToken(loginResult.getAccessToken());
}
@Override
public void onCancel() {
Log.d(TAG, "facebook:onCancel");
// ...
}
@Override
public void onError(FacebookException error) {
Log.d(TAG, "facebook:onError", error);
// ...
}
});
AuthUI.getInstance()
.signOut(this)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
finish();
}
});
Sign out
while it should already say Sign in with Facebook
. <com.facebook.login.widget.LoginButton
android:id="@+id/loginButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:layout_marginBottom="56dp"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true" />
FirebaseAuth.getInstance().signOut();
LoginManager
for Facebook authentication and did something like this: public void logOut() {
FirebaseAuth.getInstance().signOut();
LoginManager.getInstance().logOut();
}