Okay, the whole Android account authentication and sync adapters mechanism may be rather complicated at first look, and GitHub Android app adds another layer of complexity there, but I'll try to explain you the whole flow (I hope that my understanding is correct).
At first, I'd recommend you this article about Android Authenticator if you are not familiar with the subject yet. GitHub Android uses exactly the same mechanism, described in that article.
You are right, HomeActivity
is launched first. It then launches OrganizationLoader to load a list of orgs. That loader invokes method from OrganizationService
which is a part of GitHub Java API.
GitHub Android uses RoboGuice
to configure injecting of most commonly used classes like GitHub API services. You can see that OrganizationService is created in ServicesModule.
It takes GithubClient
as a constructor parameter and there is also a GitHubModule which is configured to return AccountClient when an instance of GitHubClient
is needed.
AccountClient
overrides configureRequest()
method and invokes
String token = account.getAuthToken();
This is a method of GitHubAccount class, which invokes a method from internal Android's AccountManager
. And AccountManager
is configured to use that AccountAuthenticator you've talked about, which returns LoginActivity
intent if there is no account on device.
Hope this helps :)