manages the callbacks into the FacebookSdk from an Acitivity's or Fragment's onActivityResult() method.
This javadoc of CallbackManager class from facebook sdk doesn't explain very well on how the facebook sdk interacts with our app components. It exposes just one public method : onActivityResult() which is to be called by our app's ui components from their onActivityResult.
We create an instance of class CallbackManager, using CallbackManager Factory which essentially returns a new instance of CallbackManagerImpl, the only implementation of CallbackManager interface in facebook sdk.
CallbackManagerImpl :
So, this class gets callback from our app components. But what does it do with that?
Different facebook components such as the LoginManager, AppInviteDialog register themselves with this class to be invoked for their particular case. They do so by the publicly exposed registerCallback method and register themselve against one of the request codes defined in CallbackManagerImpl.RequestCodeOffset. These two images explain this very well :
But when does these different facebook components register these callbacks?
They do that when we register our callback on these components. Sounds like a cycle, right? It is.
Let's take the example of Login Manager.
When we are using the facebook sdk to let the user log in through facebook, we register a callback on the LoginManager instance through its publicly exposed registerCallback method and with that, pass it the callbackManagerImpl instance that we have created. After this, the LoginManager registers itself on that callbackManagerImpl instance and makes sure that it'll call us when it gets back a callback. The last part, from where does callbackManagerImpl gets the callback? If you don't have an answer for this, I suggest you to read this post again.
I've tried to summarize everything is this final image :
Let me know of any doubts in a comment below.
Comments
Post a Comment