-2

i want to perform facebook logout in my application,here is my logout what i did till now

logout.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

             Session session = Session.getActiveSession();
             System.out.println("session"+session);

                singleton.fb_userid="";
                singleton.login_via_fb="";
                Intent i=new Intent(delivery.this,MainActivity.class);
                startActivity(i);
        }
    });

Here the problem is i am getting session value as null,so i get the facebook used id and based on some logic i am performing the logout.

my question is when ever i logout it not again asking the login screen rather it directly saying you are a authorized user of this app.

How can i do that,please provide some suggestions.i am using some 2 series facebook sdk.

Gajendran
  • 13
  • 6

1 Answers1

1

you can do like this

FBLogout.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            clearApplicationData();
            FBHandler.getInstance(this).facebookLogout();
            Intent i=new Intent(delivery.this,MainActivity.class);
            startActivity(i);
        }
    });

And you can put below method in FBHandler.java

public void facebookLogout() {

    AsyncFacebookRunner fbAsyncRun = new AsyncFacebookRunner(facebook);
    fbAsyncRun.logout(context, new AsyncFacebookRunner.RequestListener() {

        public void onMalformedURLException(MalformedURLException e,
                Object state) {
            printoCommon.showToastMsg((Activity) context, e.getMessage());
        }

        public void onIOException(IOException e, Object state) {
            printoCommon.showToastMsg((Activity) context, e.getMessage());
        }

        public void onFileNotFoundException(FileNotFoundException e,
                Object state) {
            printoCommon.showToastMsg((Activity) context, e.getMessage());
        }

        public void onFacebookError(FacebookError e, Object state) {
            printoCommon.showToastMsg((Activity) context, e.getMessage());
        }

        public void onComplete(String response, Object state) {
            printoCommon.showToastMsg((Activity) context,
                    "You have logged out from facebook Successfully");
            ((Activity) context).finish();
        }
    });
}
InnocentKiller
  • 5,234
  • 7
  • 36
  • 84
  • @Gajendran, still if you are facing any problem do comment, i will help you, and if this solution works for you then please accept the answer. – InnocentKiller Dec 02 '13 at 07:52