0
我們有一個要求,即在edittext中顯示主要Gmail帳戶。但是我收到了所有在我的手機中登錄的電子郵件(Gmail)帳戶。在我的手機中獲取所有gmail中的主要gmail ID
我正在使用下面的代碼。
Pattern emailPattern = Patterns.EMAIL_ADDRESS; // API level 8+
Account[] accounts = AccountManager.get(MainActivity.this).getAccountsByType("com.google");
if(accounts.length>1){
for (Account account : accounts) {
if (emailPattern.matcher(account.name).matches()) {
String possibleEmail = account.name;
Log.d("email::","email::"+possibleEmail+"----"+account.type);
}
}
}else{
Log.d("email::","email::no mails found");
}
請幫我找出主電子郵件ID。
感謝
感謝您的回覆,這裏是什麼考勤();?而且我也沒有得到主要的電子郵件。只有所有電子郵件中的電子郵件數量最多。 :( – user2432358
它什麼都沒有。 看到更新的awnser – Namy
你也可以在這裏檢查網絡連接.. – Namy