如何在 Android 上获取 google 用户名?
我见过有关使用 AccountManager
的参考,例如访问通过 Android 的 Google 帐户 ID /用户名。不过好像是为了抢authtoken
?
我只需要访问用户名,不需要密码或任何身份验证令牌。
我使用的是android 2.1 sdk。如何在 Android 上获取 google 用户名?
I've seen references to using the AccountManager
like Accessing Google Account Id /username via Android. But it seems like it's for grabbing the authtoken
?
I just need access to the username, no passwords or any auth tokens.
I'm using android 2.1 sdk. How can I get the google username on Android?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如评论中提到的,Roman 对 如何获取 Android 设备的主电子邮件地址 的回答解决了这个问题。
这是我使用的代码,它也会从电子邮件中删除用户名。
As mentioned in the comments, Roman's answer to How to get the Android device's primary e-mail address solves it.
Here's the code i used that will also strip out the username from the email.
在新的 Android 版本中,由于安全原因,您无法使用代码获取帐户:-
需要提示用户,如果用户同意,则只能继续操作。代码将如下所示:-
In new Android version you can't get the accounts with code due to security reason:-
it needs to be prompt to user, and if user agreed then only can be proceed with it.The code will be looks like below :-