4
votes

I was using facebook sdk 2.0. Today i have updated facebook sdk to 3.0. But there is login problem. When i click again and again on log in button,for one OR two time, out of 10 to 12 proper login dialog open, but other attempts faild. Here is my code:

 Util.clearCookies(getApplicationContext());
            String response = "";
            if (!response.contains("Error")) {
                SharedPreferences prefs = main.this.getSharedPreferences("userInformation", Context.MODE_PRIVATE);
                SharedPreferences.Editor editor = prefs.edit();
                editor.putString("ImageURL", null);
                editor.commit();
                //SessionStore.clear(main.this);

                loginSuccess = false;
                // do
                BLL_Friendlist chatFriendDataSource = new BLL_Friendlist(mActivity);
                chatFriendDataSource.deleteAllRecordsInFriendList();

                userImage.setImageUrl(null);
                dummy_user_Image_view.setVisibility(View.VISIBLE);

                /////////////////////////

                mFacebook = new Facebook(APP_ID);

                Session.waitForAuthCallback(mFacebook);

                mFacebook.authorize(main.this, PERMISSIONS, new AppLoginListener(mFacebook));

                mAsyncRunner = new AsyncFacebookRunner(mFacebook);

                SessionStore.restore(mFacebook, getApplicationContext());

                SessionEvents.addAuthListener(new SampleAuthListener());
                SessionEvents.addLogoutListener(new SampleLogoutListener());

Whats wrong with code?

enter image description here

1

1 Answers

0
votes

First if you do not have facebook app on your Android the login screen takes a while. And second: SessionStore.restore(mFacebook, getApplicationContext()); It cannot works if you not have connected before.