# Print output for @column tags ?>
public
static
class
ApnSetting.Builder
extends Object
java.lang.Object | |
↳ | android.telephony.data.ApnSetting.Builder |
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
:
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();
Public constructors | |
---|---|
Builder()
Default constructor for Builder. |
Public methods | |
---|---|
ApnSetting
|
build()
Builds |
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 is deprecated.
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
|
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
|
setProtocol(int protocol)
Sets the protocol to use to connect to this APN. |
ApnSetting.Builder
|
setProxyAddress(InetAddress proxy)
This method is deprecated.
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 | |
---|---|
public Builder ()
Default constructor for Builder.
public ApnSetting build ()
Builds ApnSetting
from this builder.
Returns | |
---|---|
ApnSetting |
null if setApnName(java.lang.String) or setEntryName(java.lang.String)
is empty, or setApnTypeBitmask(int) doesn't contain a valid bit,
ApnSetting built from this builder otherwise. |
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 . |
public ApnSetting.Builder setApnTypeBitmask (int apnTypeBitmask)
Sets the bitmask of APN types.
Apn types are usage categories for an APN entry. One APN entry may support multiple APN types, eg, a single APN may service regular internet traffic ("default") as well as MMS-specific connections.
The bitmask of APN types is calculated from APN types defined in ApnSetting
.
Parameters | |
---|---|
apnTypeBitmask |
int : a bitmask describing the types of the APN
Value is either 0 or a combination of ApnSetting.TYPE_DEFAULT , ApnSetting.TYPE_MMS , ApnSetting.TYPE_SUPL , ApnSetting.TYPE_DUN , ApnSetting.TYPE_HIPRI , ApnSetting.TYPE_FOTA , ApnSetting.TYPE_IMS , ApnSetting.TYPE_CBS , ApnSetting.TYPE_IA , ApnSetting.TYPE_EMERGENCY , ApnSetting.TYPE_MCX , ApnSetting.TYPE_XCAP , ApnSetting.TYPE_BIP , ApnSetting.TYPE_VSIM , and android.telephony.data.ApnSetting.TYPE_ENTERPRISE |
Returns | |
---|---|
ApnSetting.Builder |
This value cannot be null . |
public ApnSetting.Builder setAuthType (int authType)
Sets the authentication type of the APN.
Parameters | |
---|---|
authType |
int : the authentication type to set for the APN
Value is ApnSetting.AUTH_TYPE_NONE , ApnSetting.AUTH_TYPE_PAP , ApnSetting.AUTH_TYPE_CHAP , or ApnSetting.AUTH_TYPE_PAP_OR_CHAP |
Returns | |
---|---|
ApnSetting.Builder |
This value cannot be null . |
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 . |
public ApnSetting.Builder setCarrierId (int carrierId)
Sets the carrier id for this APN.
See TelephonyManager#getSimCarrierId()
which provides more background for what a
carrier ID is.
Parameters | |
---|---|
carrierId |
int : the carrier id to set for this APN |
Returns | |
---|---|
ApnSetting.Builder |
This value cannot be null . |
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 . |
public ApnSetting.Builder setMmsProxyAddress (InetAddress mmsProxy)
This method is deprecated.
use setMmsProxyAddress(java.lang.String)
instead.
Sets the address of an MMS proxy for the APN. The MMS proxy address can be an IP address
or hostname. If mmsProxy
contains both an IP address and hostname, this method
ignores the IP address.
The InetAddress
methods
getByName()
and
getAllByName()
require DNS for hostname
resolution. To avoid this requirement when setting a hostname, call
InetAddress.getByAddress(java.lang.String, byte[])
with both the
hostname and a placeholder IP address. See above
for an
example.
Parameters | |
---|---|
mmsProxy |
InetAddress : the MMS proxy address to set for the APN |
Returns | |
---|---|
ApnSetting.Builder |
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 . |
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 . |
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 . |
public ApnSetting.Builder setMvnoType (int mvnoType)
Sets the MVNO match type for this APN.
Parameters | |
---|---|
mvnoType |
int : the MVNO match type to set for this APN
Value is ApnSetting.MVNO_TYPE_SPN , ApnSetting.MVNO_TYPE_IMSI , ApnSetting.MVNO_TYPE_GID , or ApnSetting.MVNO_TYPE_ICCID |
Returns | |
---|---|
ApnSetting.Builder |
This value cannot be null . |
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 . |
public ApnSetting.Builder setOperatorNumeric (String operatorNumeric)
Sets the numeric operator ID for the APN. Numeric operator ID is defined as
Telephony.Carriers.MCC
+
Telephony.Carriers.MNC
.
Parameters | |
---|---|
operatorNumeric |
String : the numeric operator ID to set for this entry
This value may be null . |
Returns | |
---|---|
ApnSetting.Builder |
This value cannot be null . |
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 . |
See also:
public ApnSetting.Builder setProtocol (int protocol)
Sets the protocol to use to connect to this APN.
Protocol is one of the PDP_type
values in TS 27.007 section 10.1.1.
Parameters | |
---|---|
protocol |
int : the protocol to set to use to connect to this APN
Value is ApnSetting.PROTOCOL_IP , ApnSetting.PROTOCOL_IPV6 , ApnSetting.PROTOCOL_IPV4V6 , ApnSetting.PROTOCOL_PPP , ApnSetting.PROTOCOL_NON_IP , or ApnSetting.PROTOCOL_UNSTRUCTURED |
Returns | |
---|---|
ApnSetting.Builder |
This value cannot be null . |
public ApnSetting.Builder setProxyAddress (InetAddress proxy)
This method is deprecated.
use setProxyAddress(java.lang.String)
instead.
Sets the address of an HTTP proxy for the APN. The proxy address can be an IP address or
hostname. If proxy
contains both an IP address and hostname, this method ignores
the IP address.
The InetAddress
methods
getAllByName()
require DNS for hostname
resolution. To avoid this requirement when setting a hostname, call
InetAddress.getByAddress(java.lang.String, byte[])
with both the
hostname and a placeholder IP address. See above
for an
example.
Parameters | |
---|---|
proxy |
InetAddress : the proxy address to set for the APN |
Returns | |
---|---|
ApnSetting.Builder |
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 . |
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 . |
public ApnSetting.Builder setRoamingProtocol (int roamingProtocol)
Sets the protocol to use to connect to this APN when the device is roaming.
Roaming protocol is one of the PDP_type
values in TS 27.007 section 10.1.1.
Parameters | |
---|---|
roamingProtocol |
int : the protocol to set to use to connect to this APN when roaming
Value is ApnSetting.PROTOCOL_IP , ApnSetting.PROTOCOL_IPV6 , ApnSetting.PROTOCOL_IPV4V6 , ApnSetting.PROTOCOL_PPP , ApnSetting.PROTOCOL_NON_IP , or ApnSetting.PROTOCOL_UNSTRUCTURED |
Returns | |
---|---|
ApnSetting.Builder |
This value cannot be null . |
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 . |