本文介绍了Android的:如何以编程方式获取配置的电子邮件帐户地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用下面的code,以获取配置的帐户名
I used the below code to get the configured account name
Account[] accounts = AccountManager.get(this).getAccounts();
for (Account account : accounts) {
Log.d("Account", "Name " + account.name);
}
但我需要在电子邮件ID 所配置的 Microsoft Exchange帐户作为我们可以改变帐户的名称(它不需要是唯一的)的。
But i need the email id of the configured Microsoft Exchange account as we can change the name of the account (it is not need to be unique).
在此先感谢
推荐答案
这code正常工作
public class RegisteredEmailAccounts extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.registered_email_account);
final TextView accountsData = (TextView) findViewById(R.id.accounts);
String possibleEmail="";
try{
possibleEmail += "************* Get Registered Gmail Account
*************\n\n";
Account[] accounts =
AccountManager.get(this).getAccountsByType("com.google");
for (Account account : accounts) {
possibleEmail += " --> "+account.name+" : "+account.type+" , \n";
possibleEmail += " \n\n";
}
}
catch(Exception e)
{
Log.i("Exception", "Exception:"+e) ;
}
try{
possibleEmail += "**************** Get All Registered Accounts
*****************\n\n";
Account[] accounts = AccountManager.get(this).getAccounts();
for (Account account : accounts) {
possibleEmail += " --> "+account.name+" : "+account.type+" , \n";
possibleEmail += " \n";
}
}
catch(Exception e)
{
Log.i("Exception", "Exception:"+e) ;
}
// Show on screen
accountsData.setText(possibleEmail);
Log.i("Exception", "mails:"+possibleEmail) ;
}
}
这篇关于Android的:如何以编程方式获取配置的电子邮件帐户地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!