kadhirvel
kadhirvel

Reputation: 470

facebook Feed Dialog single sign on not working android

if (!facebook.isSessionValid()) {
            Log.i("FacebokLogin ", "facebook session not valid");
            facebook.authorize(FacebookUtility.this, new String[] {}, new DialogListener() {
                @Override
                public void onComplete(Bundle values) {

                    SharedPreferences.Editor editor = mPrefs.edit();
                    editor.putString("FBLaccess_token",
                            facebook.getAccessToken());
                    editor.putLong("FBLaccess_expires",
                            facebook.getAccessExpires());
                    editor.commit();
                    Log.i("FacebokLogin ", "onComplete, values: " + values);
                    shareOnFacebook();
                }   

 mFacebook.dialog(FacebookUtility.this, "feed", parameters, new UpdateStatusListener());

After authorization complete and mFacebook.dialog () executes it asks for username and password and shows feed dialog but the user is already logged in using facebook app. What can be the problem? I am testing on android 4.0 htc desire c

Upvotes: 0

Views: 260

Answers (1)

Gaurang Mody
Gaurang Mody

Reputation: 19

try this

if (!facebook.isSessionValid()) {
    facebook.authorize(this,
            new String[] { "email", "publish_stream" },
            new DialogListener() {

                @Override
                public void onCancel() {
                    // Function to handle cancel event
                }

                @Override
                public void onComplete(Bundle values) {
                    // Function to handle complete event
                    // Edit Preferences and update facebook acess_token
                    SharedPreferences.Editor editor = mPrefs.edit();
                    editor.putString("access_token",
                            facebook.getAccessToken());
                    editor.putLong("access_expires",
                            facebook.getAccessExpires());
                    editor.commit();
                }

Upvotes: 1

Related Questions