該項目的源代碼是https://github.com/github/android在Github Android項目中,LoginActivity是如何啓動的?
我找不出如何啓動LoginActivity。 HomeActivity是首次推出的活動。不知何故,LoginActivity也會啓動。一般來說,制定一個策略來跟蹤Intent何時啓動一個活動(Intent對象創建在哪裏)會很棒。在這個特定的場景中,我只想了解Github開發人員如何實現身份驗證。
該項目的源代碼是https://github.com/github/android在Github Android項目中,LoginActivity是如何啓動的?
我找不出如何啓動LoginActivity。 HomeActivity是首次推出的活動。不知何故,LoginActivity也會啓動。一般來說,制定一個策略來跟蹤Intent何時啓動一個活動(Intent對象創建在哪裏)會很棒。在這個特定的場景中,我只想了解Github開發人員如何實現身份驗證。
答案是1部分RTFM和1部分驚訝於調試器的工作原理。
Github使用AccountManager。您可以在文檔的開始:http://developer.android.com/training/id-auth/custom_auth.html#ExtendThatThing
<service
android:name=".accounts.AccountAuthenticatorService"
android:exported="false"
android:process=":auth" >
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator" />
</intent-filter>
<meta-data
android:name="android.accounts.AccountAuthenticator"
android:resource="@xml/authenticator" />
</service>
第2部分 - 通過AccountAuthenticator內設置將不會觸發,因爲它們不在同一個thread
com.github.mobile運行默認破發點。相反,它運行爲「com.github.mobile:auth」。您需要進入DDMS透視圖,以martk com.github.mobile:auth作爲可調試的斷點使用。