How to check user is alreadry logged in using facebook in social auth android

964 Views Asked by At

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.

1

There are 1 best solutions below

2
On BEST ANSWER

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!!