0

I have the following activity connecting facebook

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_facebook);
      mFacebook = SavvyActivityDelegate.get().getFacebook(this);
     if (mFacebook.isSessionValid()) {
         // TODO GET FB ACCESS TOKEN
        } else {
            mFacebook.authorize(this, FacebookConstants.PERMISSIONS, new AppFacebookDialogListener(FacebookActivity.this,mFacebook));
        }

public void onActivityResult(int request, int result, Intent data) {
      super.onActivityResult(request, result, data);
      mFacebook.authorizeCallback(request, result, data);


    }

Here goes the dialog listener used

    public class AppFacebookDialogListener implements Facebook.DialogListener {   
private final Activity activity;  
 private final Facebook facebook;

      public SavvyFacebookDialogListener(Activity activity, Facebook facebook) {
        this.activity = activity;
        this.facebook = facebook;
        Log.d(LogTag.app, "Facebook constructor");    // activity.finish();   }

  @Override   public void onComplete(Bundle values) {
    Log.d(LogTag.app, "Facebook authorization complete!");
    SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(activity).edit();
    editor.putLong("fb_access_expires", facebook.getAccessExpires());
    editor.putString("fb_access_token", facebook.getAccessToken());
    editor.commit();   }

  @Override   public void onFacebookError(FacebookError e) {
    Log.e(LogTag.app, e.getErrorType() + ": " + e.getMessage() + " (code: " + e.getErrorCode() + ")", e);   }

  @Override   public void onError(DialogError e) {
    Log.e(LogTag.app, e.getMessage(), e);   }

  @Override   public void onCancel() {
    Log.d(LogTag.app, "Facebook authorization was cancelled");   } }

The log statement on start of the activity

06-06 15:09:19.314: I/ActivityManager(404): START u0 {cmp=com.biggu.shopsavvy/.FacebookActivity} from pid 17947 06-06 15:09:19.392: D/ShopSavvy(17947): Facebook constructor 06-06 15:09:19.400: I/ActivityManager(404): START u0 {cmp=com.facebook.katana/.ProxyAuth (has extras)} from pid 17947 06-06 15:09:19.415: I/ActivityManager(404): START u0 {cmp=com.facebook.katana/.ProxyAuthDialog (has extras)} from pid 15214

So as per the logs the dialog constructor gets called but none of the callback methods get called .

If the facebook app is not installed then the code works fine and i get the callback authorization complete but the code behaves weirdly on devices with facebook app and user is logged in . Thanks in advance .

Preethi
  • 2,112
  • 7
  • 38
  • 54
  • 1
    Are you overriding the onActivityResult class in your activity? If you have the facebook app installed, it will use SSO, which calls back through the onActivityResult method. Also, you're using a deprecated method of accessing Facebook. You should use the new APIs in 3.x of the SDK. – Ming Li Jun 10 '13 at 18:18
  • Yes i am having the activity result method in my fragment .I thought facebook would still support the old sdk ? – Preethi Jun 11 '13 at 18:10
  • Is this in a fragment or an activity? If fragment, then you'll need to override the onActivityResult method in your containing activity class instead since the old version does not support Fragments. While SDK 3.x is backwards compatible, it is strongly recommended that if you're starting a new project to use the new Session paradigms. – Ming Li Jun 11 '13 at 18:33
  • No my class extends Activity and activity result never seems to be called . No errors , warning nothing at all displayed in logcat . – Preethi Jun 11 '13 at 19:06
  • Do you see any dialogs pop up from the Facebook app (asking you to authorize your app)? What version of the Facebook app are you using? – Ming Li Jun 11 '13 at 19:21
  • I am using facebook version 3.3 . If i have no facebook spp installed and invoke webview it works fine and i am able to login . But if I have the latest fb app installed(invoke com.facebook.katana/.ProxyAuthDialog) then i see "loading dialog for 2 seconds and then dialog just closes and i am back to the activity . – Preethi Jun 11 '13 at 19:24
  • It's weird that your onActivityResult is not called at all, even on failures it should still get a cancel or see something in logcat. What permissions are you asking for? – Ming Li Jun 11 '13 at 19:33
  • public static final String[] PERMISSIONS = new String[]{"publish_stream", "read_stream", "offline_access", "email"}; – Preethi Jun 11 '13 at 19:43
  • Thanks Ming li , on ActivityResult was the issue as there was parent activity for this activity and that was getting the results – Preethi Jun 11 '13 at 23:09

0 Answers0