这是否可以以编程方式添加和配置交换帐户 [英] Is this possible to add and configure an exchange account programmaticaly
问题描述
在android上我们可以通过settings->Account&sync->add account->Corporate手动添加账户,然后我们填写字段并添加账户.
On android we can add an account manually through settings->Account&sync->add account->Corporate and then we fill the fields and add the account.
我想以编程方式执行此操作.我在互联网上搜索,但没有找到任何方法来做到这一点.
I want to do this programmatically. I searched on internet but did not find any way to do this.
我发现了两个帖子(http://code.google.com/p/android/issues/detail?id=21233 AND Android 如何以编程方式添加/配置 Exchange 设置? ),之后看起来似乎不可能......但是有人知道这样做的方法吗?
I found two posts ( http://code.google.com/p/android/issues/detail?id=21233 AND Android How to add/configure Exchange setting programmatically? ), after which it looks like that it is not possible...But does any one know any way to do this?
我们可以通过Intent Settings.ACTION_ADD_ACCOUNT以编程方式打开屏幕设置->账户&同步->添加账户.我也可以填写这些字段吗?
We can programmatically open the screen settings->Account&sync->add account by intent Settings.ACTION_ADD_ACCOUNT. Can I somehow fill the fields too?
有这样做的意图吗?或者我可以以某种方式使用客户经理吗?
Is there any intent to do this? Or can I use account manager somehow?
推荐答案
我也遇到过这个问题,我得到的唯一答案是对于 Android 3.0 及更高版本是否",对于 2.3 及更低版本则不是.
I did too encounter this problem and the only answer I ever got is NO for Android 3.0 and above, and NOT REALLY for 2.3 and lower.
对于平台 2.3 及更低版本,您可以使用 Exchange 帐户创建屏幕的参数调用 Intent,因此将填充所有字段.
For platform 2.3 and lower you can call intent with parameters for the Exchange account creation screen, so all fields will be filled.
//Gingerbread and lower
ComponentName localComponentName = new ComponentName("com.android.email", "com.android.email.activity.setup.AccountSetupBasics");
Intent exchangeIntent = new Intent("android.intent.action.MAIN");
exchangeIntent.putExtra("com.android.email.AccountSetupBasics.username", mUserName);
exchangeIntent.putExtra("com.android.email.AccountSetupBasics.password", mPassword);
exchangeIntent.putExtra("com.android.email.extra.eas_flow", true);
exchangeIntent.setComponent(localComponentName);
exchangeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
(此代码基于我在堆栈交换中找到的答案,但我无法再次找到以供参考)
您必须明白,此解决方案不适用于没有默认电子邮件客户端的设备.
You must understand that this solution does not apply to devices that do not have the default eMail client.
我认为这个解决方案是一个黑客而不是一个真正的解决方案,但这是我发现的.
I consider this solution as a hack and not a real solution but this is what i'v found.
从 HoneyComb 开始,交换帐户创建屏幕已更改,并且不再从意图中获取这些参数,因此此解决方案不适用,我找不到任何其他方法来做到这一点.
From HoneyComb and onward the exchange account creation screen was changed and it does not get those parameters any more from the intent, so this solution does not apply and i could not found any other way to do it.
我尚未实施的另一个解决方案是使用第三方电子邮件客户端,该客户端提供创建、删除或修改交易所帐户所需的 API
Another solution that i have not implemented is to use a 3rd party email client which supply's needed API to create, delete or modify an exchange account
希望对我有帮助
这篇关于这是否可以以编程方式添加和配置交换帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!