简体   繁体   English

当我注销Facebook Android Studio时,我需要一个按钮消失

[英]I need that a button dissapears when I logout Facebook Android Studio

I have a problem when I logout using the Facebook API. 使用Facebook API注销时出现问题。 Apart from the button to log in and out, I have another button that allows access to other activity, what happens is that when I logout I want to disappear the button that gives me access to the other activity and I can not do it, I have tried many combinations with all methods of the main activity and nothing works 除了用于登录和注销的按钮外,我还有一个允许访问其他活动的按钮,发生的事情是,当我注销时,我想取消使我能够访问其他活动的按钮,但我无法执行此操作尝试了与主要活动的所有方法进行多种组合的方法,但无济于事

Any suggestions? 有什么建议么?

Get a reference to the Facebook Login Button and set a click listener on it and when click is registered, logout using LoginManager instance and make all your logout procedure ( such as clearing stored access token, clearing cache, etc.) and then make visibility of the other button View.GONE 获取对Facebook登录按钮的引用,并在其上设置一个单击侦听器,并在单击注册后,使用LoginManager实例注销并进行所有注销过程(例如,清除存储的访问令牌,清除缓存等),然后对其他按钮View.GONE

Eg: 例如:

LoginButton mBtnFbLogin = (LoginButton) findViewById(R.id.fb_login_button);
Button otherButton = (Button) findViewById(R.id.other_button)

Now set click listener on it. 现在在其上设置单击侦听器。

mBtnFbLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                LoginManager.getInstance().logOut();
                // Make your logout procedure
                ...
                otherButton.setVisibility(View.GONE);
            }
        });

Thank your for your answer, the solution works. 感谢您的回答,该解决方案有效。 Finally I do this: 最后,我这样做:

@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.

相关问题 Android Facebook注销:发生这种情况时,我可以在哪里运行代码? - Android Facebook Logout: Where can I make code run when this happens? 当我单击注销按钮时,如何停止android应用程序将待处理位置发送到Web服务器? - How to stop the android application sending the pending location to webserver when i clicked on the logout button? 在模拟器中运行时,按钮消失 - Button dissapears when run in emulator 当我在 Android Studio 中按下按钮时,我的应用程序崩溃 - My App Crashes When I press A Button In Android Studio 为什么我在 Android Studio 中的应用程序在我按下按钮时冻结? - Why is my app in Android Studio freezing when I press a button? Android Studio,是否有刷新按钮。 每次我在 xml 中进行更改时,我都需要关闭并重新打开工作室以查看设计的更改 - Android Studio, Is there a refresh button. Every time I make changes in xml I need to close and reopen studio to see changes on the design 需要帮助,我是 Android Studio 的初学者 - Need Help, I am a beginner on Android Studio Facebook SDK 4.4。+ | 登录后如何隐藏注销按钮? - Facebook SDK 4.4.+ | How do I hide logout button after login? 注销时如何清除 android 中的缓存? - How can i clear cache in android when logout? Android:facebook登录和注销 - Android: facebook login & logout
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM