【问题标题】:How to get the email id from android device [duplicate]如何从android设备获取电子邮件ID [重复]
【发布时间】:2014-10-19 15:53:37
【问题描述】:

我想从 android 设备获取电子邮件 ID。我看到 AccountManager 会有所帮助。但它来自 api 级别 8。我的应用程序需要支持所有 API 级别。所以请分享任何文件以获取电子邮件 ID。

【问题讨论】:

  • 支持 API 级别

标签: android


【解决方案1】:

// API 级别 5+

Pattern email = Patterns.EMAIL_ADDRESS; 
    Account[] accounts = AccountManager.get(context).getAccounts();
    for (Account account : accounts) {
        if (emailPattern.matcher(account.name).matches()) {
            String possibleEmail = account.name;
        }
    }

API 级别 14+

使用ContactsContract.Profile

Roman Nurik 的详细回答

https://stackoverflow.com/a/2175688/3020568

【讨论】:

    猜你喜欢
    • 2015-03-28
    • 2016-12-08
    • 2012-08-21
    • 2011-01-07
    • 1970-01-01
    • 2021-11-03
    • 2018-12-12
    • 2018-11-03
    相关资源
    最近更新 更多