其他分享
首页 > 其他分享> > 我无法从android中的facebook注销(Facebook SDK为3.21)

我无法从android中的facebook注销(Facebook SDK为3.21)

作者:互联网

我无法从android中的facebook注销. Facebook SDK是3.21

 public void logoutFromFacebook() {

        facebook = new Facebook(APP_ID);
        mAsyncRunner = new AsyncFacebookRunner(facebook);

        mAsyncRunner.logout(this, new AsyncFacebookRunner.RequestListener() {

            @Override
            public void onComplete(String response, Object state) {
                Log.d("Logout from Facebook", response);
                if (Boolean.parseBoolean(response) == true) {
                    // User successfully Logged out
                    Log.d("Dilip Logout successfully", "");

                }
            }

            @Override
            public void onIOException(IOException e, Object state) {

            }

            @Override
            public void onFileNotFoundException(FileNotFoundException e, Object state) {

            }

            @Override
            public void onMalformedURLException(MalformedURLException e, Object state) {

            }

            @Override
            public void onFacebookError(FacebookError e, Object state) {

            }


        });
}

Logcat错误为

Logout from Facebook: {“error_code”:101,”error_msg”:”Invalid application ID. (101)”,”request_args”:[{“key”:”format”,”value”:”json”},{“key”:”method”,”value”:”auth.expireSession”}]}

解决方法:

您的logcat返回

Invalid application ID.

您可以使用Facebook SDK 4.阅读官员文件LoginManager

Session is used to authenticate a user and manage the user’s session
with Facebook.
Sessions must be opened before they can be used to make a Request.
When a Session is created, it attempts to initialize itself from a
TokenCachingStrategy. Closing the session can optionally clear this
cache. The Session lifecycle uses SessionState to indicate its state.
Once a Session has been closed, it can’t be re-opened; a new Session
must be created.

FacebookSdk.sdkInitialize(getApplicationContext());

然后

LoginManager.getInstance().logOut();

标签:android-facebook,android
来源: https://codeday.me/bug/20191119/2034838.html