How to get the default gmail username and password [closed]

笑着哭i 提交于 2021-02-16 15:42:08

问题


Now I am doing a android project. The project needs to get the default username and password of Android phone.

I don't know how to get the default gmail information of one Android Cell Phone. Can u help me. Thanks.


回答1:


You should read about AccountManager to login using the gmail user but you will not get the username and password.




回答2:


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

Note that this requires the GET_ACCOUNTS permission:



来源:https://stackoverflow.com/questions/2817581/how-to-get-the-default-gmail-username-and-password

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!