Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have android app in my app am login with facebook and also am sharing messages on my wall but my problem is when i click logout button i have to delete alldetails of facebook because when i click login button it must ask username and password. how can i do please provide any code. thanks in advance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
235 views
Welcome To Ask or Share your Answers For Others

1 Answer

Use this code:

fb_logout.setOnClickListener(new OnClickListener() {


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

                    fb_Logout();

            }
        });
        public boolean fb_Logout() {
        Toast.makeText(getApplicationContext(),
                "You are logged out from Facebook.", Toast.LENGTH_LONG).show();

        try {
            Log.d("Tests", "Testing logout");
            String response = authenticatedFacebook.logout(this);
            if (!response.equals("true")) {
                return false;
            }
            Log.d("Tests", "Testing logout on logged out facebook session");
            try {
                Util.parseJson(authenticatedFacebook.logout(this));
                return false;
            } catch (FacebookError e) {
                if (e.getErrorCode() != 101
                        || !e.getMessage().equals("Invalid API key")) {
                    return false;
                }
            }
            try {
                Util.parseJson(new Facebook(APP_ID).logout(this));
                return false;
            } catch (FacebookError e) {
                if (e.getErrorCode() != 101
                        || !e.getMessage().equals("Invalid API key")) {
                    return false;
                }
            }
            return true;
        } catch (Throwable e) {
            e.printStackTrace();
            return false;
        }

    }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...