7

This is my code for logging in to facebook.

mLoginButton = (LoginButton) findViewById(R.id.login);

        // restore session if one exists
        SessionStore.restore(Utility.mFacebook, this);
        SessionEvents.addAuthListener(new FbAPIsAuthListener());
        SessionEvents.addLogoutListener(new FbAPIsLogoutListener());

        /*
         * Source Tag: login_tag
         */
        mLoginButton.init(this, AUTHORIZE_ACTIVITY_RESULT_CODE, Utility.mFacebook, permissions);

        if (Utility.mFacebook.isSessionValid()) {
            requestUserData();
        }
 public class FbAPIsAuthListener implements AuthListener {

        //@Override
        public void onAuthSucceed() {
            requestUserData();
        }

        //@Override
        public void onAuthFail(String error) {
            mText.setText("Login Failed: " + error);
        }
    }

    /*
     * The Callback for notifying the application when log out starts and
     * finishes.
     */
    public class FbAPIsLogoutListener implements LogoutListener {
        //@Override
        public void onLogoutBegin() {
            mText.setText("Logging out...");
        }

        ///@Override
        public void onLogoutFinish() {
            mText.setText("You have logged out! ");
            mUserPic.setImageBitmap(null);
        }
    }

On emulator it works perfect. I have tried in ton 3 devices, that have already facebook installed and here is the problem.

it just spinning aroun on loading and it does nothing. I see the login button again. Then i tried to logout from the original facebook application, and when pressing the login button on my app, i see the login window but now that I used to see when logging in the emulator but the login window of the original facebook application. Like is has started this one.

the code I am using is taken from the hackbook.java

qwerty_gr
  • 318
  • 3
  • 7
  • 15
  • Do you have the facebook application installed on the emulator like you have in the devices(s)? Also, there are currently problems with the android sdk, as it states in the [Platform Status](http://developers.facebook.com/live_status/). You can also try to run a network sniffer to check the responses – Nitzan Tomer Apr 20 '12 at 16:31
  • no in the emulator it is not installed. – qwerty_gr Apr 20 '12 at 16:39

2 Answers2

5

The Platform Status says that there's a problem with the SSO.

The SSO only works if you have the facebook application installed on the android device, and what you describe fits right into all of this. On the emulator you don't have the facebook application, and so when your application tries to log the user in it uses the dialog it has in the sdk instead of using the SSO process that ships with the fb application.

On the device how ever you said that you do have the fb app, and so the SSO kicks in and, at least currently, there's a problem with it. Try to uninstall the facebook application on the device or maybe just cancel the SSO, i.e.: How to disable Facebook single sign on for android - Facebook-android-sdk

Community
  • 1
  • 1
Nitzan Tomer
  • 155,636
  • 47
  • 315
  • 299
  • if I unistall it, it runs but the thing is that the normal user obviously will not unistall the original facebook app to install mine's. – qwerty_gr Apr 20 '12 at 18:41
  • Clearly, I was just suggesting that to make sure that the problem you have is due to the problem facebook is having with the SSO. Now that we know that it's the problem you have nothing to do but wait till they fix the problem. It's a risk you're taking with working with other APIs. – Nitzan Tomer Apr 20 '12 at 18:46
  • any particular solutions for this or any fixes for this? – Nitesh Verma Aug 09 '14 at 08:51
0

You need to generate the hash key of your system and just place it by editing the existing facebook App.

kamal_tech_view
  • 4,235
  • 4
  • 28
  • 49