Deprecated
in API level 27
Class Overview
This class contains all the account information for a given email account
Summary
[Expand]
Inherited Constants |
From interface
android.os.Parcelable
int |
CONTENTS_FILE_DESCRIPTOR |
|
int |
PARCELABLE_WRITE_RETURN_VALUE |
|
|
Public Constructors |
|
EmailAccount()
|
|
EmailAccount(String emailAddress, String inComingProtocol, String inComingServerAddress, int inComingServerPort, String inComingServerLogin, String inComingServerPassword, String outGoingProtocol, String outGoingServerAddress, int outGoingServerPort, String outGoingServerLogin, String outGoingServerPassword)
Struct to add a new email account.
|
[Expand]
Inherited Methods |
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
|
From interface
android.os.Parcelable
abstract
int
|
describeContents()
|
abstract
void
|
writeToParcel(Parcel arg0, int arg1)
|
|
Fields
public
String
emailAddress
Since: API level 11
public
String
incomingProtocol
Since: API level 11
public
boolean
incomingServerAcceptAllCertificates
Since: API level 11
Accept All Certificates when InComing Server
public
String
incomingServerAddress
Since: API level 11
public
String
incomingServerLogin
Since: API level 11
public
String
incomingServerPassword
Since: API level 11
public
int
incomingServerPort
Since: API level 11
public
boolean
incomingServerUseSSL
Since: API level 11
use SSL when InComing Server
public
boolean
incomingServerUseTLS
Since: API level 11
use TLS when InComing Server
public
boolean
isNotify
Since: API level 11
public
String
outgoingProtocol
Since: API level 11
public
boolean
outgoingServerAcceptAllCertificates
Since: API level 11
Accept All Certificates when Outgoing Server
public
String
outgoingServerAddress
Since: API level 11
public
String
outgoingServerLogin
Since: API level 11
public
String
outgoingServerPassword
Since: API level 11
public
int
outgoingServerPort
Since: API level 11
public
boolean
outgoingServerUseSSL
Since: API level 11
use SSL when Outgoing Server
public
boolean
outgoingServerUseTLS
Since: API level 11
use TLS when Outgoing Server
public
String
signature
Since: API level 11
Signature to use with the account
Public Constructors
public
EmailAccount
(String emailAddress, String inComingProtocol, String inComingServerAddress, int inComingServerPort, String inComingServerLogin, String inComingServerPassword, String outGoingProtocol, String outGoingServerAddress, int outGoingServerPort, String outGoingServerLogin, String outGoingServerPassword)
Struct to add a new email account.
Parameters
emailAddress
| Email address of the email account |
inComingProtocol
| Incoming server protocol |
inComingServerAddress
| Incoming server address |
inComingServerPort
| Incoming server port number |
inComingServerLogin
| Incoming server login/username |
inComingServerPassword
| Incoming server password |
outGoingProtocol
| Outgoing server protocol |
outGoingServerAddress
| Outgoing server address |
outGoingServerPort
| OutgGoing server port number |
outGoingServerLogin
| Outgoing server login/username |
outGoingServerPassword
| Outgoing server password |
long accountId = -1;
EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
EmailAccountPolicy emailAccountPolicy = edm.getEmailAccountPolicy();
try {
accountId = emailAccountPolicy.addNewAccount(new EmailAccount(
"testemail@gmail.com","pop3","pop.gmail.com", 995,
"testemail@gmail.com", null,"smtp", "smtp.gmail.com",465,
"testemail@gmail.com",null));
if(accountId >= 0){
Log.d(TAG," Adding a new email account has succeeded!");
// Administrator needs to call sendAccountsChangedBroadcast() API
// to notify regarding email account addition.
emailAccountPolicy.sendAccountsChangedBroadcast();
}else{
Log.d(TAG," Adding a new email account failed.");
}
} catch(SecurityException e) {
Log.w(TAG,"SecurityException: "+e);
}
|
For Container:
long accountId = -1;
// When you create container successfully, containerID will be returned via intent.
// Use this containerID in below API.
EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
EmailAccountPolicy emailAccountPolicy = kcm.getEmailAccountPolicy();
try {
accountId = emailAccountPolicy.addNewAccount(new EmailAccount(
"testemail@gmail.com","pop3","pop.gmail.com", 995,
"testemail@gmail.com", null,"smtp", "smtp.gmail.com",465,
"testemail@gmail.com",null));
if(accountId >= 0){
Log.d(TAG," Adding a new email account has succeeded!");
// Administrator needs to call sendAccountsChangedBroadcast() API
// to notify regarding email account addition.
emailAccountPolicy.sendAccountsChangedBroadcast();
}else{
Log.d(TAG," Adding a new email account failed.");
}
} catch(SecurityException e) {
Log.w(TAG,"SecurityException: "+e);
}
|