我们正在尝试使用以下代码片段以编程方式在三星设备上添加 Exchange 帐户。
long accountId = -1;
try
{
EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(AfariaMain.getAppContext());
ExchangeAccountPolicy exchangeAccountPolicy = edm.getExchangeAccountPolicy();
accountId = exchangeAccountPolicy.addNewAccount(new ExchangeAccount(emailAddress, easUser, easDomain, serverAddress, serverPassword));
} catch(SecurityException e)
{
ALog.e(TAG,"SecurityException: "+e);
}
return accountId;
我们面临的问题是,对于 Android 10 及更高版本的设备,对“exchangeAccountPolicy.addNewAccount”的调用返回帐户 ID 为 -1。