antonkrasov / AndroidSocialNetworks

Library for easy work with Facebook, Twitter, LinkedIn and Google on Android
1.03k stars 260 forks source link

Calling .isConnected() #19

Closed devloe closed 10 years ago

devloe commented 10 years ago

What's the best moment to call .isConnected()?

Calling it inside onSocialNetworkManagerInitialized() always returns false.

On the other hand, I find it hard to understand the correct flow. This is what I plan to do:

Is this reasoning ok to you?

Anyway, the library is awesome.

antonkrasov commented 10 years ago

@devyanlab, Hi, Did you check api_demos project? I think you can just copy code from there, it already contains all what you need. Just check login demo, in it I enable/disable buttons if user is logginned or not.

devloe commented 10 years ago

Thats what im doing. The thing is that I dont get when is the right time to call isConnected(). If I setup a Hanlder with a timeout of 2 seconds, and execute isConnected(), then I get `true. Otherwise, I getfalse``.

antonkrasov commented 10 years ago

Thats really strange, here is implementation of isConnected():


@Override
    public boolean isConnected() {
        String accessToken = mSharedPreferences.getString(SAVE_STATE_KEY_OAUTH_TOKEN, null);
        String accessTokenSecret = mSharedPreferences.getString(SAVE_STATE_KEY_OAUTH_SECRET, null);
        return accessToken != null && accessTokenSecret != null;
    }

I can't understand how you can get false, if you really connected. This is implementation for Twitter and LinkedIn, for Facebook it's different, are we talking about Facebook?

devloe commented 10 years ago

I get falseright after initializing SocialNetworkManager. If I call isConnected() 2 seconds after that, I get true.

And i'm testing it with Google+.

devloe commented 10 years ago

Nevermind. I don't need to do that anymore, I took another path.

Anyways, it is really strange tho.

antonkrasov commented 10 years ago

@devyanlab, I need to double check this, as I just call isConnected from Google Plus client:

@Override
    public boolean isConnected() {
        return mPlusClient.isConnected();
    }