Android How to add/configure Exchange setting programmatically?

对着背影说爱祢 提交于 2019-12-20 02:13:55

问题


Is it me or I can't find any example of how to add/configure Microsoft Exchange programatically?

It seems like

AccountManager ::

addAccount (String accountType, String authTokenType, String[] requiredFeatures, Bundle addAccountOptions, Activity activity, AccountManagerCallback<Bundle> callback, Handler handler)

should do the work. However, I can't figure out how for Microsoft Exchange account. Could you point me to a simple working example code?

Thank you.


回答1:


Seems like it can't be done by applications.

you'll get the following exception:

ERROR/AndroidRuntime(442): Caused by: java.lang.SecurityException: caller uid xxxxx is different than the authenticator's uid

you'll get this exception because the account manager verifies that the application that wrote the exchange authenticator (Google) is the same one that is creating the account. here's a post that explains AccountManager's logic in that case.




回答2:


Android's AccountManager only adds sync based accounts, binding the provider and authenticator, helping authenticate credentials of the given account. Even after you would have taken care of the UID warning, you still need to populate the Exchange account settings properly, including those of sync look back etc. In short, you might need to be a system user app to work with the restricted content URI from email account.



来源:https://stackoverflow.com/questions/4056043/android-how-to-add-configure-exchange-setting-programmatically

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