简体   繁体   English

Android为什么没有显示Facebook SDK Logout按钮?

[英]Android Why Facebook SDK Logout button not showing?

I have developed an app with facebook login, there is no problem in the login process. 我用facebook登录开发了一个应用程序,登录过程没有问题。 But I do not see the button when I want to logout. 但是当我想要注销时,我没有看到按钮。

Broken App Screenshot 破碎的应用截图

破解APP

Working App Screenshot 工作应用截图

工作APP

Broken app gradle files; 破碎的应用程序gradle文件;

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.1"
    defaultConfig {
        applicationId "com.ex.ex"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {

    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    // Glide image library
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:design:24.2.1'
    compile 'com.android.support:support-v4:24.2.1'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.google.android.gms:play-services-auth:9.2.1'
    compile 'com.facebook.android:facebook-android-sdk:4.1.0'

    testCompile 'junit:junit:4.12'
}

apply plugin: 'com.google.gms.google-services'

What is the source of the problem? 这个问题的根源是什么? How can i fix this? 我怎样才能解决这个问题?

Thanks. 谢谢。

Try to Follow Facebook for Android Documentation 尝试关注Facebook获取Android文档

and use Latest Version compile 'com.android.support:appcompat-v7:25.2.0' 并使用最新版本compile 'com.android.support:appcompat-v7:25.2.0'

Follow this tutorial 请遵循本教程

compile 'com.google.android.gms:play-services:10.2.0'

I am assuming you have used LoginButton widget of Facebook android sdk. 我假设你已经使用了Facebook android sdk的LoginButton小部件。

When you click logout of LoginButton widget following code executes : 在代码执行后单击LoginButton小部件的注销时:

    protected void performLogout(Context context) {
        final LoginManager loginManager = getLoginManager();
        if (confirmLogout) {
            // Create a confirmation dialog
            String logout = getResources().getString(
                    R.string.com_facebook_loginview_log_out_action);
            String cancel = getResources().getString(
                    R.string.com_facebook_loginview_cancel_action);
            String message;
            Profile profile = Profile.getCurrentProfile();
            if (profile != null && profile.getName() != null) {
                message = String.format(
                        getResources().getString(
                                R.string.com_facebook_loginview_logged_in_as),
                        profile.getName());
            } else {
                message = getResources().getString(
                        R.string.com_facebook_loginview_logged_in_using_facebook);
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(context);
            builder.setMessage(message)
                    .setCancelable(true)
                    .setPositiveButton(logout, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            loginManager.logOut();
                        }
                    })
                    .setNegativeButton(cancel, null);
            builder.create().show();
        } else {
            loginManager.logOut();
        }

} }

confirmLogout flag is by default set to true unless specified false in widget xml file: 除非在widget xml文件中指定false,否则confirmLogout标志默认设置为true:

confirmLogout = a.getBoolean(R.styleable.com_facebook_login_view_com_facebook_confirm_logout, true);

So please check your xml file whether confirm_logout is set to false. 因此,请检查您的xml文件是否将confirm_logout设置为false。 But in that case, user will be logged out silently without displaying alert dialog. 但在这种情况下,用户将以静默方式注销而不显示警告对话框。

Please post your jave code and xml code, if problem is still not resolved. 如果问题仍未解决,请发布您的jave代码和xml代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM