ApnSetting.Builder | API reference | Android Developers
public
static
class
ApnSetting.Builder
extends Object
Provides a convenient way to set the fields of a ApnSetting when creating a new
instance. The following settings are required to build an ApnSetting:
- apnTypeBitmask
- apnName
- entryName
The example below shows how you might create a new ApnSetting:
// Create an MMS proxy address with a hostname. A network might not be
// available, so supply a placeholder (0.0.0.0) IPv4 address to avoid DNS lookup.
String host = "mms.example.com";
byte[] ipAddress = new byte[4];
InetAddress mmsProxy;
try {
mmsProxy = InetAddress.getByAddress(host, ipAddress);
} catch (UnknownHostException e) {
e.printStackTrace();
return;
}
ApnSetting apn = new ApnSetting.Builder()
.setApnTypeBitmask(ApnSetting.TYPE_DEFAULT | ApnSetting.TYPE_MMS)
.setApnName("apn.example.com")
.setEntryName("Example Carrier APN")
.setMmsc(Uri.parse("http://mms.example.com:8002"))
.setMmsProxyAddress(mmsProxy)
.setMmsProxyPort(8799)
.build();
Summary
Public constructors | |
|---|---|
Builder()
Default constructor for Builder. |
|
Public methods | |
|---|---|
ApnSetting
|
build()
Builds |
ApnSetting.Builder
|
setAlwaysOn(boolean alwaysOn)
Sets whether the PDU session brought up by this APN should always be on. |
ApnSetting.Builder
|
setApnName(String apnName)
Sets the name of the APN. |
ApnSetting.Builder
|
setApnTypeBitmask(int apnTypeBitmask)
Sets the bitmask of APN types. |
ApnSetting.Builder
|
setAuthType(int authType)
Sets the authentication type of the APN. |
ApnSetting.Builder
|
setCarrierEnabled(boolean carrierEnabled)
Sets the current status for this APN. |
ApnSetting.Builder
|
setCarrierId(int carrierId)
Sets the carrier id for this APN. |
ApnSetting.Builder
|
setEntryName(String entryName)
Sets a human-readable name that describes the APN. |
ApnSetting.Builder
|
setMmsProxyAddress(InetAddress mmsProxy)
This method was deprecated
in API level 29.
use |
ApnSetting.Builder
|
setMmsProxyAddress(String mmsProxy)
Sets the MMS proxy address of the APN. |
ApnSetting.Builder
|
setMmsProxyPort(int mmsPort)
Sets the MMS proxy port of the APN. |
ApnSetting.Builder
|
setMmsc(Uri mmsc)
Sets the MMSC Uri of the APN. |
ApnSetting.Builder
|
setMtuV4(int mtuV4)
Set the default MTU (Maximum Transmission Unit) size in bytes of the IPv4 routes brought up by this APN setting. |
ApnSetting.Builder
|
setMtuV6(int mtuV6)
Set the default MTU (Maximum Transmission Unit) size in bytes of the IPv6 routes brought up by this APN setting. |
ApnSetting.Builder
|
setMvnoType(int mvnoType)
Sets the MVNO match type for this APN. |
ApnSetting.Builder
|
setNetworkTypeBitmask(int networkTypeBitmask)
Sets Radio Technology (Network Type) info for this APN. |
ApnSetting.Builder
|
setOperatorNumeric(String operatorNumeric)
Sets the numeric operator ID for the APN. |
ApnSetting.Builder
|
setPassword(String password)
Sets the APN password of the APN. |
ApnSetting.Builder
|
setPersistent(boolean isPersistent)
Set if the APN setting should be persistent/non-persistent in modem. |
ApnSetting.Builder
|
setProfileId(int profileId)
Sets the profile id to which the APN saved in modem. |
ApnSetting.Builder
|
setProtocol(int protocol)
Sets the protocol to use to connect to this APN. |
ApnSetting.Builder
|
setProxyAddress(InetAddress proxy)
This method was deprecated
in API level 29.
use |
ApnSetting.Builder
|
setProxyAddress(String proxy)
Sets the proxy address of the APN. |
ApnSetting.Builder
|
setProxyPort(int port)
Sets the proxy port of the APN. |
ApnSetting.Builder
|
setRoamingProtocol(int roamingProtocol)
Sets the protocol to use to connect to this APN when the device is roaming. |
ApnSetting.Builder
|
setUser(String user)
Sets the APN username of the APN. |
Inherited methods | |||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
From class
| |||||||||||||||||||||||
Public constructors
Builder
public Builder ()
Default constructor for Builder.
Public methods
setAlwaysOn
public ApnSetting.Builder setAlwaysOn (boolean alwaysOn)
Sets whether the PDU session brought up by this APN should always be on. See 3GPP TS 23.501 section 5.6.13
| Parameters | |
|---|---|
alwaysOn |
boolean: the always on status to set for this APN |
| Returns | |
|---|---|
ApnSetting.Builder |
This value cannot be null. |
setApnName
public ApnSetting.Builder setApnName (String apnName)
Sets the name of the APN.
| Parameters | |
|---|---|
apnName |
String: the name to set for the APN.
This value may be null. |
| Returns | |
|---|---|
ApnSetting.Builder |
This value cannot be null. |
setCarrierEnabled
public ApnSetting.Builder setCarrierEnabled (boolean carrierEnabled)
Sets the current status for this APN.
| Parameters | |
|---|---|
carrierEnabled |
boolean: the current status to set for this APN |
| Returns | |
|---|---|
ApnSetting.Builder |
This value cannot be null. |
setEntryName
public ApnSetting.Builder setEntryName (String entryName)
Sets a human-readable name that describes the APN.
| Parameters | |
|---|---|
entryName |
String: the entry name to set for the APN.
This value may be null. |
| Returns | |
|---|---|
ApnSetting.Builder |
This value cannot be null. |
setMmsProxyAddress
public ApnSetting.Builder setMmsProxyAddress (String mmsProxy)
Sets the MMS proxy address of the APN.
| Parameters | |
|---|---|
mmsProxy |
String: the MMS proxy address to set for the APN.
This value may be null. |
| Returns | |
|---|---|
ApnSetting.Builder |
This value cannot be null. |
setMmsProxyPort
public ApnSetting.Builder setMmsProxyPort (int mmsPort)
Sets the MMS proxy port of the APN.
| Parameters | |
|---|---|
mmsPort |
int: the MMS proxy port to set for the APN |
| Returns | |
|---|---|
ApnSetting.Builder |
This value cannot be null. |
setMmsc
public ApnSetting.Builder setMmsc (Uri mmsc)
Sets the MMSC Uri of the APN.
| Parameters | |
|---|---|
mmsc |
Uri: the MMSC Uri to set for the APN.
This value may be null. |
| Returns | |
|---|---|
ApnSetting.Builder |
This value cannot be null. |
setMtuV4
public ApnSetting.Builder setMtuV4 (int mtuV4)
Set the default MTU (Maximum Transmission Unit) size in bytes of the IPv4 routes brought
up by this APN setting. Note this value will only be used when MTU size is not provided
in DataCallResponse#getMtuV4() during network bring up.
| Parameters | |
|---|---|
mtuV4 |
int: the MTU size in bytes of the route. |
| Returns | |
|---|---|
ApnSetting.Builder |
This value cannot be null. |
setMtuV6
public ApnSetting.Builder setMtuV6 (int mtuV6)
Set the default MTU (Maximum Transmission Unit) size in bytes of the IPv6 routes brought
up by this APN setting. Note this value will only be used when MTU size is not provided
in DataCallResponse#getMtuV6() during network bring up.
| Parameters | |
|---|---|
mtuV6 |
int: the MTU size in bytes of the route. |
| Returns | |
|---|---|
ApnSetting.Builder |
This value cannot be null. |
setNetworkTypeBitmask
public ApnSetting.Builder setNetworkTypeBitmask (int networkTypeBitmask)
Sets Radio Technology (Network Type) info for this APN.
| Parameters | |
|---|---|
networkTypeBitmask |
int: the Radio Technology (Network Type) info |
| Returns | |
|---|---|
ApnSetting.Builder |
This value cannot be null. |
setPassword
public ApnSetting.Builder setPassword (String password)
Sets the APN password of the APN.
| Parameters | |
|---|---|
password |
String: the APN password to set for the APN.
This value may be null. |
| Returns | |
|---|---|
ApnSetting.Builder |
This value cannot be null. |
setPersistent
public ApnSetting.Builder setPersistent (boolean isPersistent)
Set if the APN setting should be persistent/non-persistent in modem.
| Parameters | |
|---|---|
isPersistent |
boolean: true if this APN setting should be persistent/non-persistent
in modem. |
| Returns | |
|---|---|
ApnSetting.Builder |
The same instance of the builder.
This value cannot be null. |
setProfileId
public ApnSetting.Builder setProfileId (int profileId)
Sets the profile id to which the APN saved in modem.
| Parameters | |
|---|---|
profileId |
int: the profile id to set for the APN. |
| Returns | |
|---|---|
ApnSetting.Builder |
This value cannot be null. |
setProxyAddress
public ApnSetting.Builder setProxyAddress (String proxy)
Sets the proxy address of the APN.
| Parameters | |
|---|---|
proxy |
String: the proxy address to set for the APN.
This value may be null. |
| Returns | |
|---|---|
ApnSetting.Builder |
This value cannot be null. |
setProxyPort
public ApnSetting.Builder setProxyPort (int port)
Sets the proxy port of the APN.
| Parameters | |
|---|---|
port |
int: the proxy port to set for the APN |
| Returns | |
|---|---|
ApnSetting.Builder |
This value cannot be null. |
setUser
public ApnSetting.Builder setUser (String user)
Sets the APN username of the APN.
| Parameters | |
|---|---|
user |
String: the APN username to set for the APN.
This value may be null. |
| Returns | |
|---|---|
ApnSetting.Builder |
This value cannot be null. |