[英]Facebook login intergration in android login button changes to logout after logged in
[英]Shows Logout Button after confirm login and goes to activity while login using Facebook Login Integration Android
我正在為我的Android應用程序使用Facebook登錄集成。 我可以登錄並轉到下一個活動,但是問題是,使用facebook登錄按鈕登錄后,在單擊Yes確認頁面並進入我的活動后,它會顯示一段時間的facebook注銷按鈕。 請幫我解決這個問題。
如果您成功登錄,則使用Facebook登錄按鈕。它將把措辭從“登錄Facebook”更改為“注銷”。 如果使用意圖,請按如下所示設置標志
Intent next = new Intent(getApplicationContext(), MenuActivity.class);
next.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(next);
以下是Facebook登錄按鈕的示例
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
GraphRequest request = GraphRequest.newMeRequest(AccessToken.getCurrentAccessToken(), (object, response) -> {
// hide this facebook login button
// Intent to your desired activity
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,email,birthday,gender,first_name,last_name");
request.setParameters(parameters);
request.executeAsync();
}
@Override
public void onCancel() {
Toast.makeText(getApplicationContext(), Message.LOGINCANCEL, Toast.LENGTH_SHORT).show();
}
@Override
public void onError(FacebookException e) {
Toast.makeText(getApplicationContext(), Message.LOGINFAILED, Toast.LENGTH_SHORT).show();
}
});
如果要將“注銷” Facebook按鈕更改為“登錄Facebook”,請使用以下代碼。.只需創建BUtton並執行onClick()即可觸發以下代碼
if (AccessToken.getCurrentAccessToken() != null && com.facebook.Profile.getCurrentProfile() != null){
LoginManager.getInstance().logOut();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.