2011-12-12 29 views
2

我已經看過thisthis,但它們使它聽起來像它必須是使用Google登錄的網站(而不是Android應用程序),而不是我自己的數據庫。我可以讓我的應用中的用戶使用Google登錄嗎?

那麼,是否有可能使用Google登錄,以及如何使用Google在Android應用中創建帳戶?很抱歉,如果這個問題很模糊,但我不知道還有什麼要問的。

回答

3

那麼你可以嘗試使用AuthenticatorManager和使用已經在您的設備鏈接的谷歌帳戶,這也適用於其他賬戶的Twitter,LinkedIn,Facebook等

你可以找到在Android的代碼示例, SampleSyncAdapter,這可以讓你開始,如果你急着嘗試使用Native Account和Sync Adapter,你可能想嘗試谷歌代碼2011中使用C2DM and AppEngine的例子,就像你在this post上看到的那樣,他們要求他們的帳號是連接上。

當您可以使用電話帳戶時,無需使用OpenID,但您必須在遠程存儲庫OpenID上使用該機制才能將令牌發送到服務器。

1

可以使用Google登錄Android應用程序。

Android AccountManager class has access to this。 參考:http://developer.android.com/reference/android/accounts/AccountManager.html

此類提供訪問用戶的在線帳戶的集中註冊表。用戶每個帳戶輸入一次憑據(用戶名和密碼),通過「單擊」批准授予應用程序訪問在線資源的權限。

您可以按照以下代碼檢索與手機關聯的Google帳戶。

List<String> googleAccounts = new ArrayList<String>(); 
Account[] accounts = AccountManager.get(this).getAccounts(); 
for (Account account : accounts) { 
    if (account.type.equals("com.google")) { 
    googleAccounts.add(account.name); 
    } 
} 

而且在AndroidManifest.xml

添加 「GET_ACCOUNTS」 權限
相關問題