Builder

open class Builder
kotlin.Any
   ↳ 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:

  • 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 dummy (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(); 

Requires API level 28 (Android 8.+, P)

Summary

Public constructors

Default constructor for Builder.

Public methods
open ApnSetting.Builder!
setAuthType(authType: Int)

Sets the authentication type of the APN.

open ApnSetting.Builder!
setUser(user: String!)

Sets the APN username of the APN.

open ApnSetting.Builder!
setMvnoType(mvnoType: Int)

Sets the MVNO match type for this APN.

open ApnSetting.Builder!
setNetworkTypeBitmask(networkTypeBitmask: Int)

Sets Radio Technology (Network Type) info for this APN.

open ApnSetting.Builder!
setEntryName(entryName: String!)

Sets a human-readable name that describes the APN.

open ApnSetting.Builder!
setPassword(password: String!)

Sets the APN password of the APN.

open ApnSetting.Builder!
setApnTypeBitmask(apnTypeBitmask: Int)

Sets the bitmask of APN types.

open ApnSetting.Builder!
setProtocol(protocol: Int)

Sets the protocol to use to connect to this APN.

open ApnSetting!

Builds ApnSetting from this builder.

open ApnSetting.Builder!

Sets the address of an HTTP proxy for the APN.

open ApnSetting.Builder!
setMmsc(mmsc: Uri!)

Sets the MMSC Uri of the APN.

open ApnSetting.Builder!
setMmsProxyPort(mmsPort: Int)

Sets the MMS proxy port of the APN.

open ApnSetting.Builder!
setApnName(apnName: String!)

Sets the name of the APN.

open ApnSetting.Builder!
setRoamingProtocol(roamingProtocol: Int)

Sets the protocol to use to connect to this APN when the device is roaming.

open ApnSetting.Builder!

Sets the proxy port of the APN.

open ApnSetting.Builder!

Sets the address of an MMS proxy for the APN.

open ApnSetting.Builder!
setCarrierEnabled(carrierEnabled: Boolean)

Sets the current status for this APN.

open ApnSetting.Builder!
setOperatorNumeric(operatorNumeric: String!)

Sets the numeric operator ID for the APN.

Public constructors

<init>

Builder()

Default constructor for Builder.

Public methods

setAuthType

added in API level 28
open fun setAuthType(authType: Int): ApnSetting.Builder!

Sets the authentication type of the APN.
Requires API level 28 (Android 8.+, P)

Parameters
authType Int: the authentication type to set for the APN Value is android.telephony.data.ApnSetting#AUTH_TYPE_NONE, android.telephony.data.ApnSetting#AUTH_TYPE_PAP, android.telephony.data.ApnSetting#AUTH_TYPE_CHAP, or android.telephony.data.ApnSetting#AUTH_TYPE_PAP_OR_CHAP

setUser

added in API level 28
open fun setUser(user: String!): ApnSetting.Builder!

Sets the APN username of the APN.
Requires API level 28 (Android 8.+, P)

Parameters
user String!: the APN username to set for the APN

setMvnoType

added in API level 28
open fun setMvnoType(mvnoType: Int): ApnSetting.Builder!

Sets the MVNO match type for this APN.
Requires API level 28 (Android 8.+, P)

Parameters
mvnoType Int: the MVNO match type to set for this APN Value is android.telephony.data.ApnSetting#MVNO_TYPE_SPN, android.telephony.data.ApnSetting#MVNO_TYPE_IMSI, android.telephony.data.ApnSetting#MVNO_TYPE_GID, or android.telephony.data.ApnSetting#MVNO_TYPE_ICCID

setNetworkTypeBitmask

added in API level 28
open fun setNetworkTypeBitmask(networkTypeBitmask: Int): ApnSetting.Builder!

Sets Radio Technology (Network Type) info for this APN.
Requires API level 28 (Android 8.+, P)

Parameters
networkTypeBitmask Int: the Radio Technology (Network Type) info

setEntryName

added in API level 28
open fun setEntryName(entryName: String!): ApnSetting.Builder!

Sets a human-readable name that describes the APN.
Requires API level 28 (Android 8.+, P)

Parameters
entryName String!: the entry name to set for the APN

setPassword

added in API level 28
open fun setPassword(password: String!): ApnSetting.Builder!

Sets the APN password of the APN.
Requires API level 28 (Android 8.+, P)

Parameters
password String!: the APN password to set for the APN

setApnTypeBitmask

added in API level 28
open fun setApnTypeBitmask(apnTypeBitmask: Int): ApnSetting.Builder!

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.
Requires API level 28 (Android 8.+, P)

Parameters
apnTypeBitmask Int: a bitmask describing the types of the APN Value is either 0 or a combination of android.telephony.data.ApnSetting#TYPE_DEFAULT, android.telephony.data.ApnSetting#TYPE_MMS, android.telephony.data.ApnSetting#TYPE_SUPL, android.telephony.data.ApnSetting#TYPE_DUN, android.telephony.data.ApnSetting#TYPE_HIPRI, android.telephony.data.ApnSetting#TYPE_FOTA, android.telephony.data.ApnSetting#TYPE_IMS, android.telephony.data.ApnSetting#TYPE_CBS, android.telephony.data.ApnSetting#TYPE_IA, and android.telephony.data.ApnSetting#TYPE_EMERGENCY

setProtocol

added in API level 28
open fun setProtocol(protocol: Int): ApnSetting.Builder!

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.
Requires API level 28 (Android 8.+, P)

Parameters
protocol Int: the protocol to set to use to connect to this APN Value is android.telephony.data.ApnSetting#PROTOCOL_IP, android.telephony.data.ApnSetting#PROTOCOL_IPV6, android.telephony.data.ApnSetting#PROTOCOL_IPV4V6, or android.telephony.data.ApnSetting#PROTOCOL_PPP

build

added in API level 28
open fun build(): ApnSetting!

Builds ApnSetting from this builder.
Requires API level 28 (Android 8.+, P)

Return
ApnSetting!: null if #setApnName(String) or #setEntryName(String) is empty, or #setApnTypeBitmask(int) doesn't contain a valid bit, ApnSetting built from this builder otherwise.

setProxyAddress

added in API level 28
open fun setProxyAddress(proxy: InetAddress!): ApnSetting.Builder!

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 java.net.InetAddress methods getAllByName() require DNS for hostname resolution. To avoid this requirement when setting a hostname, call java.net.InetAddress#getByAddress(java.lang.String, byte[]) with both the hostname and a dummy IP address. See above for an example.
Requires API level 28 (Android 8.+, P)

Parameters
proxy InetAddress!: the proxy address to set for the APN

setMmsc

added in API level 28
open fun setMmsc(mmsc: Uri!): ApnSetting.Builder!

Sets the MMSC Uri of the APN.
Requires API level 28 (Android 8.+, P)

Parameters
mmsc Uri!: the MMSC Uri to set for the APN

setMmsProxyPort

added in API level 28
open fun setMmsProxyPort(mmsPort: Int): ApnSetting.Builder!

Sets the MMS proxy port of the APN.
Requires API level 28 (Android 8.+, P)

Parameters
mmsPort Int: the MMS proxy port to set for the APN

setApnName

added in API level 28
open fun setApnName(apnName: String!): ApnSetting.Builder!

Sets the name of the APN.
Requires API level 28 (Android 8.+, P)

Parameters
apnName String!: the name to set for the APN

setRoamingProtocol

added in API level 28
open fun setRoamingProtocol(roamingProtocol: Int): ApnSetting.Builder!

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.
Requires API level 28 (Android 8.+, P)

Parameters
roamingProtocol Int: the protocol to set to use to connect to this APN when roaming Value is android.telephony.data.ApnSetting#PROTOCOL_IP, android.telephony.data.ApnSetting#PROTOCOL_IPV6, android.telephony.data.ApnSetting#PROTOCOL_IPV4V6, or android.telephony.data.ApnSetting#PROTOCOL_PPP

setProxyPort

added in API level 28
open fun setProxyPort(port: Int): ApnSetting.Builder!

Sets the proxy port of the APN.
Requires API level 28 (Android 8.+, P)

Parameters
port Int: the proxy port to set for the APN

setMmsProxyAddress

added in API level 28
open fun setMmsProxyAddress(mmsProxy: InetAddress!): ApnSetting.Builder!

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 java.net.InetAddress methods getByName() and getAllByName() require DNS for hostname resolution. To avoid this requirement when setting a hostname, call java.net.InetAddress#getByAddress(java.lang.String, byte[]) with both the hostname and a dummy IP address. See above for an example.
Requires API level 28 (Android 8.+, P)

Parameters
mmsProxy InetAddress!: the MMS proxy address to set for the APN

setCarrierEnabled

added in API level 28
open fun setCarrierEnabled(carrierEnabled: Boolean): ApnSetting.Builder!

Sets the current status for this APN.
Requires API level 28 (Android 8.+, P)

Parameters
carrierEnabled Boolean: the current status to set for this APN

setOperatorNumeric

added in API level 28
open fun setOperatorNumeric(operatorNumeric: String!): ApnSetting.Builder!

Sets the numeric operator ID for the APN. Numeric operator ID is defined as android.provider.Telephony.Carriers#MCC + android.provider.Telephony.Carriers#MNC.
Requires API level 28 (Android 8.+, P)

Parameters
operatorNumeric String!: the numeric operator ID to set for this entry