如何在 Android 手机上找回已登录的 Google 帐户?
我正在开发一个 Android 应用程序,我需要检索手机上使用的 Google 帐户。我想为 C2DM 执行此操作,但我不想要求用户输入他/她的 Google 电子邮件帐户(如果他们已经登录)。有什么方法可以做到吗?
I am developing an Android application and I need to retrieve the Google account used on the phone. I want to do this for the C2DM, but I don't want to ask the user to enter in his/her Google email account if they are already logged in. Is there any way to do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
像这样的东西应该可以工作:
并且您将需要清单中的以下权限:
如果您支持 Android 6 及更高版本,请记住“在运行时请求权限”
https://developer.android.com/training/permissions/requesting.html
这是我凭记忆写的,所以可能需要一些调整。显然现在可以在没有电子邮件地址的情况下注册,因此也许可以对数据进行一些正则化以确保它实际上是一个电子邮件地址(确保它包含@gmail或@googlemail)
Something like this should work:
And you will need the following permission in your manifest:
Remember to 'Requesting Permissions at Run Time' if you support Android 6 and later
https://developer.android.com/training/permissions/requesting.html
I wrote this from memory so it may need a little tweaking. Apparently it's possible to register now without an email address, so maybe do some regexing on the data to ensure it's actually an email address (ensure it contains @gmail or @googlemail)
我尝试在以下范围内获取电子邮件地址和用户名
在您的手机中获取Google帐户
在您的手机中获取Google帐户用户名< /strong>
声明对 mainfest 文件的权限。
I have try below scope to get email address and username
Get Google account in your mobile
Get Google accounts user name in your mobile
declare permissions to your mainfest file.