簡體   English   中英

Android為什么沒有顯示Facebook SDK Logout按鈕?

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

我用facebook登錄開發了一個應用程序,登錄過程沒有問題。 但是當我想要注銷時,我沒有看到按鈕。

破碎的應用截圖

破解APP

工作應用截圖

工作APP

破碎的應用程序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'

這個問題的根源是什么? 我怎樣才能解決這個問題?

謝謝。

嘗試關注Facebook獲取Android文檔

並使用最新版本compile 'com.android.support:appcompat-v7:25.2.0'

請遵循本教程

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

我假設你已經使用了Facebook android sdk的LoginButton小部件。

在代碼執行后單擊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();
        }

}

除非在widget xml文件中指定false,否則confirmLogout標志默認設置為true:

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

因此,請檢查您的xml文件是否將confirm_logout設置為false。 但在這種情況下,用戶將以靜默方式注銷而不顯示警告對話框。

如果問題仍未解決,請發布您的jave代碼和xml代碼。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM