[英]Android Facebook Logout: Where can I make code run when this happens?
[英]I need that a button dissapears when I logout Facebook Android Studio
使用Facebook API注銷時出現問題。 除了用於登錄和注銷的按鈕外,我還有一個允許訪問其他活動的按鈕,發生的事情是,當我注銷時,我想取消使我能夠訪問其他活動的按鈕,但我無法執行此操作嘗試了與主要活動的所有方法進行多種組合的方法,但無濟於事
有什么建議么?
獲取對Facebook登錄按鈕的引用,並在其上設置一個單擊偵聽器,並在單擊注冊后,使用LoginManager實例注銷並進行所有注銷過程(例如,清除存儲的訪問令牌,清除緩存等),然后對其他按鈕View.GONE
例如:
LoginButton mBtnFbLogin = (LoginButton) findViewById(R.id.fb_login_button);
Button otherButton = (Button) findViewById(R.id.other_button)
現在在其上設置單擊偵聽器。
mBtnFbLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LoginManager.getInstance().logOut();
// Make your logout procedure
...
otherButton.setVisibility(View.GONE);
}
});
感謝您的回答,該解決方案有效。 最后,我這樣做:
@Override
protected void onResume() {
super.onResume();
AppEventsLogger.activateApp(this);
if (AccessToken.getCurrentAccessToken() != null && com.facebook.Profile.getCurrentProfile() != null) {
boton_volver.setVisibility(View.VISIBLE);
boton_volver.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent;
intent = new Intent(v.getContext(), EventosActivity.class);
startActivity(intent);
}
});
} else {
boton_volver.setVisibility(View.INVISIBLE);
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.