1

I am implementing social-auth library in android application its working fine, but i want to check that if user already login with facebook or not.

Example: If user logged in facebook prior then always show logged in for facebook(any for which user is logged in.) no click should be required.

Charles
  • 50,943
  • 13
  • 104
  • 142
Jagdish
  • 2,418
  • 4
  • 25
  • 51

1 Answers1

4

After googled a lot. I found a solution.

facebookAdapter = new SocialAuthAdapter(new ResponseListener());

        String token = null;
        try {
            token = facebookAdapter.getCurrentProvider().getAccessGrant().getKey();
        } catch (Exception e) {
            // TODO: handle exception
        }

        if(token==null)
            facebookAdapter.authorize(MainActivity.this, Provider.FACEBOOK);
        else
            facebookAdapter.getUserProfileAsync(new ProfileDataListener());

if token!=null then user is already login.

I hope this will help others!!Thanks!!

Jagdish
  • 2,418
  • 4
  • 25
  • 51
  • 2
    Have you tested it with the latest version? After successful login, getCurrentProvider() returns null anyway. Maybe there is another way to check if a user is logged in? – Bartosz Ostrowski Feb 06 '14 at 21:13
  • but what if app logged-in with FB, Twitter both...for which service it will return status...how it can be rectified...any suggestion? – CoDe Apr 19 '14 at 21:24