3

I am not able to logout from facebook in android. Facebook sdk is 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 Error is

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

Arulkumar
  • 12,966
  • 14
  • 47
  • 68
Dilip
  • 2,622
  • 1
  • 20
  • 27
  • check this http://stackoverflow.com/questions/10975266/facebook-error-application-id-is-invalid you created new object of facebook which is not authorized.. so make facebook object singleton – virendrao Dec 22 '15 at 06:38
  • http://stackoverflow.com/questions/8323449/how-to-logout-using-facebook-api-in-android – IntelliJ Amiya Dec 22 '15 at 06:41
  • 1
    please refer this link. it may help you. http://stackoverflow.com/questions/14328148/how-to-programmatically-log-out-from-facebook-sdk-3-0-without-using-facebook-log – MFP Dec 22 '15 at 06:42

1 Answers1

3

Your logcat returns

Invalid application ID.

You can use Facebook SDK 4 . Read Officials Document 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());

Then

LoginManager.getInstance().logOut();
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198