简体   繁体   English

如何在具有Google帐户的Android中使用AccountManager?

[英]How can I use AccountManager in Android with Google Account?

I want to use AccountManager in Android, to verify a com.google account. 我想在Android中使用AccountManager来验证com.google帐户。 I've already know how to get the account, But I've got several questions, 我已经知道如何获得该帐户,但是我有几个问题,

  1. If the account is not in AccountManager, and the account self is under com.google domain, then how can I add it? 如果该帐户不在AccountManager中,并且该帐户本身在com.google域下,那么如何添加它?
  2. How AccountManager manage tokens? AccountManager如何管理令牌? It retrieves tokens automatically, or I need to do it manually? 它会自动检索令牌,还是我需要手动进行?
  3. I'm trying to use Google Reader API with ClientLogin, then I may need password for the first time. 我试图将Google Reader API与ClientLogin一起使用,那么我可能第一次需要密码。 If some com.google accounts are stored previously by other apps, can I use them to get the password? 如果某些com.google帐户以前是由其他应用存储的,我可以使用它们来获取密码吗?

Edit on 2011.08.20 编辑于2011.08.20

To clarify the question, what I want to ask it this, 为了澄清这个问题,我想问什么,

  1. Google applications on Android has its own routine to verify Google accounts, and I want to know whether it's possible to call the routine created by Google applications, and get my own authority? Android上的Google应用程序具有自己的例程来验证Google帐户,我想知道是否可以调用Google应用程序创建的例程并获得我自己的权限?
  2. If there's no Google Account on Android phone, how can I add an account, which will be accepted by Google applications later? 如果Android手机上没有Google帐户,该如何添加一个帐户,以后该帐户会被Google应用程序接受?

If the account is not in AccountManager, and the account self is under com.google domain, then how can I add it? 如果该帐户不在AccountManager中,并且该帐户本身在com.google域下,那么如何添加它?

If you simply want to have, for example, a button that lets the user add a Google account, consider invoking the ADD_ACCOUNT intent. 例如,如果您仅想使用一个按钮来允许用户添加Google帐户,请考虑调用ADD_ACCOUNT意图。 Another, more advanced, option is to use AccountManager.addAccount . 另一个更高级的选择是使用AccountManager.addAccount

How AccountManager manage tokens? AccountManager如何管理令牌? It retrieves tokens automatically, or I need to do it manually? 它会自动检索令牌,还是我需要手动进行?

The system manages tokens. 系统管理令牌。 Well, actually, applications register 'authenticators' which manage tokens for their corresponding service. 好吧,实际上,应用程序注册了“身份验证器”,该“身份验证器”管理其相应服务的令牌。 An authenticator for Google accounts comes preloaded with most Android devices, and third party apps like Twitter add their own authenticators when installed. 大多数Android设备都预装有Google帐户的身份验证器,而Twitter等第三方应用程序在安装时会添加自己的身份验证器。 Apps that want to use Google accounts can request authentication tokens using AccountManager.getAuthToken . 想要使用Google帐户的应用可以使用AccountManager.getAuthToken请求身份验证令牌。

I'm trying to use Google Reader API with ClientLogin, then I may need password for the first time. 我试图将Google Reader API与ClientLogin一起使用,那么我可能第一次需要密码。 If some com.google accounts are stored previously by other apps, can I use them to get the password? 如果某些com.google帐户以前是由其他应用存储的,我可以使用它们来获取密码吗?

Your app should never ask the user for her Google password . 您的应用程序绝不应向用户询问她的Google密码 Use the relevant AccountManager methods to request an auth token for Reader. 使用相关的AccountManager方法为Reader请求身份验证令牌。 Unfortunately, since Google Reader doesn't have a public API I can't assist further. 不幸的是,由于Google阅读器没有公共API,因此我们无法提供进一步的帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我无法使用AccountManager获得我的Google帐户? - Why don't I get my Google account with AccountManager? 使用Android的AccountManager添加自定义帐户 - Adding a custom account using Android's AccountManager 如何使AccountManager每个用户名处理多个帐户? - How can I make AccountManager handle multiple accounts per username? Android:如何验证我的Google帐户以及如何获取我的GMail任务? - Android: how do I authenticate to my google account and how can I get my GMail Tasks? Android AccountManager抛出AuthenticatorException:添加帐户时绑定失败 - Android AccountManager throws AuthenticatorException: bind failure when adding account 在Android Studio中,如何更改带有圆角边框的google帐户的照片? - In Android Studio how can I change the photo of the google account with the rounded border? 如何使用API​​服务器端将我的帐户中的数据提供给Google登录用户? - How can I use API server side to provide datas from my account to a google signed in user? AccountManager帐户选择者意图 - AccountManager account chooser intent 如何从AccountManager.getAccounts()获取与特定帐户关联的图标 - How to get an icon associated with specific Account from AccountManager.getAccounts() 是否有使用AccountManager帐户在Android上对Google Data API进行身份验证的官方方法? - Is there an official way to authenticate for Google Data API on Android using AccountManager accounts?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM