我看过this和this但是他们认为它必须是一个网站(不是Android应用)才能使用Google登录,而不是我的数据库自己的。
那么,是否可以使用Google登录,以及如何使用Google在Android应用中创建帐户?对不起,如果这个问题含糊不清,但我不知道还有什么要问。
答案 0 :(得分:3)
您可以尝试使用AuthenticatorManager并使用已在您设备上链接的Google帐户,这也适用于其他帐户Twitter,LinkedIn,Facebook等。
您可以在Android代码示例上找到SampleSyncAdapter,这可以帮助您入门,如果您赶时间并且已经尝试使用原生帐户和同步适配器,您可能需要尝试使用Google Code 2011的示例C2DM and AppEngine正如您在this post上看到的那样,他们会要求帐户与他们建立联系。
当您可以使用电话帐户时,无需使用OpenID,您必须在远程存储库OpenID上使用该机制将令牌发送到服务器。
答案 1 :(得分:1)
可以使用Google登录Android应用程序。
Android AccountManager 类可以访问此内容。 参考: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”权限