在android中错误注销facebook api

时间:2015-07-15 15:09:05

标签: android facebook-login android-facebook

我有以下错误:

07-15 12:01:35.190    2580-2580/net.simplifiedcoding.androidlogin E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: net.simplifiedcoding.androidlogin, PID: 2580
null
        at com.facebook.internal.Validate.sdkInitialized(Validate.java:99)
        at com.facebook.FacebookSdk.getApplicationContext(FacebookSdk.java:379)
        at com.facebook.AccessTokenManager.getInstance(AccessTokenManager.java:78)
        at com.facebook.AccessToken.getCurrentAccessToken(AccessToken.java:141)
        at com.developer.Social.FBLoginFragment.logout(FBLoginFragment.java:169)
        at com.developer.groupselfie.UpdateActivity$1.onClick(UpdateActivity.java:46)
        at android.view.View.performClick(View.java:4780)
        at android.view.View$PerformClick.run(View.java:19866)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5257)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

带错误的方法是:

    public static void logout() {
    AccessToken accessToken = AccessToken.getCurrentAccessToken();
    if(accessToken != null){
        LoginManager.getInstance().logOut();
    }
}

特别是这一行:

AccessToken accessToken = AccessToken.getCurrentAccessToken();

有些帮助吗?或者可能是另一种注销方法?

1 个答案:

答案 0 :(得分:0)

你确定已经完成了

FacebookSdk.sdkInitialize(context);

在拨打logout()功能之前的某个时间?