ApnSetting
public
class
ApnSetting
extends Object
implements
Parcelable
java.lang.Object | |
↳ | android.telephony.data.ApnSetting |
An Access Point Name (APN) configuration for a carrier data connection.
The APN provides configuration to connect a cellular network device to an IP data network. A
carrier uses the name, type and other configuration in an APNSetting
to decide which IP
address to assign, any security methods to apply, and how the device might be connected to
private networks.
Use ApnSetting.Builder
to create new instances.
Summary
Nested classes | |
---|---|
class |
ApnSetting.Builder
Provides a convenient way to set the fields of a |
Constants | |
---|---|
int |
AUTH_TYPE_CHAP
Authentication type for CHAP. |
int |
AUTH_TYPE_NONE
Authentication is not required. |
int |
AUTH_TYPE_PAP
Authentication type for PAP. |
int |
AUTH_TYPE_PAP_OR_CHAP
Authentication type for PAP or CHAP. |
int |
MVNO_TYPE_GID
MVNO type for group identifier level 1. |
int |
MVNO_TYPE_ICCID
MVNO type for ICCID. |
int |
MVNO_TYPE_IMSI
MVNO type for IMSI. |
int |
MVNO_TYPE_SPN
MVNO type for service provider name. |
int |
PROTOCOL_IP
Internet protocol. |
int |
PROTOCOL_IPV4V6
Virtual PDP type introduced to handle dual IP stack UE capability. |
int |
PROTOCOL_IPV6
Internet protocol, version 6. |
int |
PROTOCOL_NON_IP
Transfer of Non-IP data to external packet data network. |
int |
PROTOCOL_PPP
Point to point protocol. |
int |
PROTOCOL_UNSTRUCTURED
Transfer of Unstructured data to the Data Network via N6. |
int |
TYPE_BIP
APN type for BIP. |
int |
TYPE_CBS
APN type for CBS. |
int |
TYPE_DEFAULT
APN type for default data traffic. |
int |
TYPE_DUN
APN type for DUN traffic. |
int |
TYPE_EMERGENCY
APN type for Emergency PDN. |
int |
TYPE_ENTERPRISE
APN type for ENTERPRISE. |
int |
TYPE_FOTA
APN type for accessing the carrier's FOTA portal, used for over the air updates. |
int |
TYPE_HIPRI
APN type for HiPri traffic. |
int |
TYPE_IA
APN type for IA Initial Attach APN. |
int |
TYPE_IMS
APN type for IMS. |
int |
TYPE_MCX
APN type for MCX (Mission Critical Service) where X can be PTT/Video/Data |
int |
TYPE_MMS
APN type for MMS traffic. |
int |
TYPE_OEM_PAID
APN type for OEM_PAID networks (Automotive PANS) |
int |
TYPE_OEM_PRIVATE
APN type for OEM_PRIVATE networks (Automotive PANS) |
int |
TYPE_RCS
APN type for RCS (Rich Communication Services). |
int |
TYPE_SUPL
APN type for SUPL assisted GPS. |
int |
TYPE_VSIM
APN type for VSIM. |
int |
TYPE_XCAP
APN type for XCAP. |
Inherited constants |
---|
Fields | |
---|---|
public
static
final
Creator<ApnSetting> |
CREATOR
|
Public methods | |
---|---|
int
|
describeContents()
Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
boolean
|
equals(Object o)
Indicates whether some other object is "equal to" this one. |
String
|
getApnName()
Returns the name of the APN. |
int
|
getApnTypeBitmask()
Returns the bitmask of APN types. |
int
|
getAuthType()
Returns the authentication type of the APN. |
int
|
getCarrierId()
Returns the carrier id for this APN. |
String
|
getEntryName()
Gets the human-readable name that describes the APN. |
int
|
getId()
Returns the unique database id for this entry. |
InetAddress
|
getMmsProxyAddress()
This method was deprecated
in API level 29.
use |
String
|
getMmsProxyAddressAsString()
Returns the MMS proxy address of the APN. |
int
|
getMmsProxyPort()
Returns the MMS proxy port of the APN. |
Uri
|
getMmsc()
Returns the MMSC Uri of the APN. |
int
|
getMtuV4()
Returns the default MTU (Maximum Transmission Unit) size in bytes of the IPv4 routes brought up by this APN setting. |
int
|
getMtuV6()
Returns the MTU size of the IPv6 mobile interface to which the APN connected. |
int
|
getMvnoType()
Returns the MVNO match type for this APN. |
int
|
getNetworkTypeBitmask()
Returns a bitmask describing the Radio Technologies (Network Types) which this APN may use. |
String
|
getOperatorNumeric()
Returns the numeric operator ID for the APN. |
String
|
getPassword()
Returns the APN password of the APN. |
int
|
getProfileId()
Returns the profile id to which the APN saved in modem. |
int
|
getProtocol()
Returns the protocol to use to connect to this APN. |
InetAddress
|
getProxyAddress()
This method was deprecated
in API level 29.
use |
String
|
getProxyAddressAsString()
Returns the proxy address of the APN. |
int
|
getProxyPort()
Returns the proxy address of the APN. |
int
|
getRoamingProtocol()
Returns the protocol to use to connect to this APN while the device is roaming. |
String
|
getUser()
Returns the APN username of the APN. |
int
|
hashCode()
Returns a hash code value for the object. |
boolean
|
isAlwaysOn()
Returns whether User Plane resources have to be activated during every transition from CM-IDLE mode to CM-CONNECTED state for this APN See 3GPP TS 23.501 section 5.6.13 |
boolean
|
isEnabled()
Returns the current status of APN. |
boolean
|
isPersistent()
Returns if the APN setting is persistent on the modem. |
void
|
writeToParcel(Parcel dest, int flags)
Flatten this object in to a Parcel. |
Inherited methods | |
---|---|
Constants
AUTH_TYPE_CHAP
public static final int AUTH_TYPE_CHAP
Authentication type for CHAP.
Constant Value: 2 (0x00000002)
AUTH_TYPE_NONE
public static final int AUTH_TYPE_NONE
Authentication is not required.
Constant Value: 0 (0x00000000)
AUTH_TYPE_PAP
public static final int AUTH_TYPE_PAP
Authentication type for PAP.
Constant Value: 1 (0x00000001)
AUTH_TYPE_PAP_OR_CHAP
public static final int AUTH_TYPE_PAP_OR_CHAP
Authentication type for PAP or CHAP.
Constant Value: 3 (0x00000003)
MVNO_TYPE_GID
public static final int MVNO_TYPE_GID
MVNO type for group identifier level 1.
Constant Value: 2 (0x00000002)
MVNO_TYPE_ICCID
public static final int MVNO_TYPE_ICCID
MVNO type for ICCID.
Constant Value: 3 (0x00000003)
MVNO_TYPE_IMSI
public static final int MVNO_TYPE_IMSI
MVNO type for IMSI.
Constant Value: 1 (0x00000001)
MVNO_TYPE_SPN
public static final int MVNO_TYPE_SPN
MVNO type for service provider name.
Constant Value: 0 (0x00000000)
PROTOCOL_IP
public static final int PROTOCOL_IP
Internet protocol.
Constant Value: 0 (0x00000000)
PROTOCOL_IPV4V6
public static final int PROTOCOL_IPV4V6
Virtual PDP type introduced to handle dual IP stack UE capability.
Constant Value: 2 (0x00000002)
PROTOCOL_IPV6
public static final int PROTOCOL_IPV6
Internet protocol, version 6.
Constant Value: 1 (0x00000001)
PROTOCOL_NON_IP
public static final int PROTOCOL_NON_IP
Transfer of Non-IP data to external packet data network.
Constant Value: 4 (0x00000004)
PROTOCOL_PPP
public static final int PROTOCOL_PPP
Point to point protocol.
Constant Value: 3 (0x00000003)
PROTOCOL_UNSTRUCTURED
public static final int PROTOCOL_UNSTRUCTURED
Transfer of Unstructured data to the Data Network via N6.
Constant Value: 5 (0x00000005)
TYPE_BIP
public static final int TYPE_BIP
APN type for BIP.
Constant Value: 8192 (0x00002000)
TYPE_CBS
public static final int TYPE_CBS
APN type for CBS.
Constant Value: 128 (0x00000080)
TYPE_DEFAULT
public static final int TYPE_DEFAULT
APN type for default data traffic.
Constant Value: 17 (0x00000011)
TYPE_DUN
public static final int TYPE_DUN
APN type for DUN traffic.
Constant Value: 8 (0x00000008)
TYPE_EMERGENCY
public static final int TYPE_EMERGENCY
APN type for Emergency PDN. This is not an IA apn, but is used for access to carrier services in an emergency call situation.
Constant Value: 512 (0x00000200)
TYPE_ENTERPRISE
public static final int TYPE_ENTERPRISE
APN type for ENTERPRISE.
Constant Value: 16384 (0x00004000)
TYPE_FOTA
public static final int TYPE_FOTA
APN type for accessing the carrier's FOTA portal, used for over the air updates.
Constant Value: 32 (0x00000020)
TYPE_HIPRI
public static final int TYPE_HIPRI
APN type for HiPri traffic.
Constant Value: 16 (0x00000010)
TYPE_IA
public static final int TYPE_IA
APN type for IA Initial Attach APN.
Constant Value: 256 (0x00000100)
TYPE_IMS
public static final int TYPE_IMS
APN type for IMS.
Constant Value: 64 (0x00000040)
TYPE_MCX
public static final int TYPE_MCX
APN type for MCX (Mission Critical Service) where X can be PTT/Video/Data
Constant Value: 1024 (0x00000400)
TYPE_MMS
public static final int TYPE_MMS
APN type for MMS traffic.
Constant Value: 2 (0x00000002)
TYPE_OEM_PAID
public static final int TYPE_OEM_PAID
APN type for OEM_PAID networks (Automotive PANS)
Constant Value: 65536 (0x00010000)
TYPE_OEM_PRIVATE
public static final int TYPE_OEM_PRIVATE
APN type for OEM_PRIVATE networks (Automotive PANS)
Constant Value: 131072 (0x00020000)
TYPE_RCS
public static final int TYPE_RCS
APN type for RCS (Rich Communication Services).
Constant Value: 32768 (0x00008000)
TYPE_SUPL
public static final int TYPE_SUPL
APN type for SUPL assisted GPS.
Constant Value: 4 (0x00000004)
TYPE_VSIM
public static final int TYPE_VSIM
APN type for VSIM.
Constant Value: 4096 (0x00001000)
TYPE_XCAP
public static final int TYPE_XCAP
APN type for XCAP.
Constant Value: 2048 (0x00000800)
Fields
Public methods
describeContents
public int describeContents ()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation. For example, if the object will
include a file descriptor in the output of writeToParcel(android.os.Parcel, int)
,
the return value of this method must include the
CONTENTS_FILE_DESCRIPTOR
bit.
Returns | |
---|---|
int |
a bitmask indicating the set of special object types marshaled
by this Parcelable object instance.
Value is either 0 or CONTENTS_FILE_DESCRIPTOR |
equals
public boolean equals (Object o)
Indicates whether some other object is "equal to" this one.
The equals
method implements an equivalence relation
on non-null object references:
- It is reflexive: for any non-null reference value
x
,x.equals(x)
should returntrue
. - It is symmetric: for any non-null reference values
x
andy
,x.equals(y)
should returntrue
if and only ify.equals(x)
returnstrue
. - It is transitive: for any non-null reference values
x
,y
, andz
, ifx.equals(y)
returnstrue
andy.equals(z)
returnstrue
, thenx.equals(z)
should returntrue
. - It is consistent: for any non-null reference values
x
andy
, multiple invocations ofx.equals(y)
consistently returntrue
or consistently returnfalse
, provided no information used inequals
comparisons on the objects is modified. - For any non-null reference value
x
,x.equals(null)
should returnfalse
.
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.
Parameters | |
---|---|
o |
Object : the reference object with which to compare. |
Returns | |
---|---|
boolean |
true if this object is the same as the obj
argument; false otherwise. |
getApnName
public String getApnName ()
Returns the name of the APN.
Returns | |
---|---|
String |
APN name |
getApnTypeBitmask
public int getApnTypeBitmask ()
Returns 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
.
Returns | |
---|---|
int |
a bitmask describing the types of the APN
Value is either 0 or a combination of TYPE_DEFAULT , TYPE_MMS , TYPE_SUPL , TYPE_DUN , TYPE_HIPRI , TYPE_FOTA , TYPE_IMS , TYPE_CBS , TYPE_IA , TYPE_EMERGENCY , TYPE_MCX , TYPE_XCAP , TYPE_BIP , TYPE_VSIM , TYPE_ENTERPRISE , TYPE_RCS , TYPE_OEM_PAID , and TYPE_OEM_PRIVATE |
getAuthType
public int getAuthType ()
Returns the authentication type of the APN.
Returns | |
---|---|
int |
authentication type
Value is android.telephony.data.ApnSetting.AUTH_TYPE_UNKNOWN, AUTH_TYPE_NONE , AUTH_TYPE_PAP , AUTH_TYPE_CHAP , or AUTH_TYPE_PAP_OR_CHAP |
getCarrierId
public int getCarrierId ()
Returns the carrier id for this APN.
Returns | |
---|---|
int |
the carrier id |
See also:
getEntryName
public String getEntryName ()
Gets the human-readable name that describes the APN.
Returns | |
---|---|
String |
the entry name for the APN |
getId
public int getId ()
Returns the unique database id for this entry.
Returns | |
---|---|
int |
the unique database id |
getMmsProxyAddress
public InetAddress getMmsProxyAddress ()
This method was deprecated
in API level 29.
use getMmsProxyAddressAsString()
instead.
Gets the MMS proxy address configured for the APN. The MMS proxy address might be an IP
address or hostname. This method returns null
if system networking (typically DNS)
isn\u2019t available to resolve a hostname value\u2014values set as IP addresses don\u2019t have this
restriction. This is a known problem and will be addressed in a future release.
Returns | |
---|---|
InetAddress |
the MMS proxy address or null if DNS isn\u2019t available to resolve a hostname |
getMmsProxyAddressAsString
public String getMmsProxyAddressAsString ()
Returns the MMS proxy address of the APN.
Returns | |
---|---|
String |
MMS proxy address. |
getMmsProxyPort
public int getMmsProxyPort ()
Returns the MMS proxy port of the APN.
Returns | |
---|---|
int |
MMS proxy port |
getMmsc
public Uri getMmsc ()
Returns the MMSC Uri of the APN.
Returns | |
---|---|
Uri |
MMSC Uri. |
getMtuV4
public int getMtuV4 ()
Returns 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.
Returns | |
---|---|
int |
the MTU size in bytes of the route. |
getMtuV6
public int getMtuV6 ()
Returns the MTU size of the IPv6 mobile interface to which the APN connected. Note this value
will only be used when MTU size is not provided in DataCallResponse#getMtuV6()
during network bring up.
Returns | |
---|---|
int |
the MTU size in bytes of the route. |
getMvnoType
public int getMvnoType ()
Returns the MVNO match type for this APN.
Returns | |
---|---|
int |
the MVNO match type
Value is android.telephony.data.ApnSetting.MVNO_TYPE_UNKNOWN, MVNO_TYPE_SPN , MVNO_TYPE_IMSI , MVNO_TYPE_GID , or MVNO_TYPE_ICCID |
See also:
getNetworkTypeBitmask
public int getNetworkTypeBitmask ()
Returns a bitmask describing the Radio Technologies (Network Types) which this APN may use.
NetworkType bitmask is calculated from NETWORK_TYPE defined in TelephonyManager
.
Examples of Network Types include TelephonyManager.NETWORK_TYPE_UNKNOWN
,
TelephonyManager.NETWORK_TYPE_GPRS
, TelephonyManager.NETWORK_TYPE_EDGE
.
Returns | |
---|---|
int |
a bitmask describing the Radio Technologies (Network Types) or 0 if it is undefined. |
getOperatorNumeric
public String getOperatorNumeric ()
Returns the numeric operator ID for the APN. Numeric operator ID is defined as
Telephony.Carriers.MCC
+
Telephony.Carriers.MNC
.
Returns | |
---|---|
String |
the numeric operator ID |
getPassword
public String getPassword ()
Returns the APN password of the APN.
Returns | |
---|---|
String |
APN password |
getProfileId
public int getProfileId ()
Returns the profile id to which the APN saved in modem.
Returns | |
---|---|
int |
the profile id of the APN |
getProtocol
public int getProtocol ()
Returns 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.
Returns | |
---|---|
int |
the protocol
Value is PROTOCOL_IP , PROTOCOL_IPV6 , PROTOCOL_IPV4V6 , PROTOCOL_PPP , PROTOCOL_NON_IP , or PROTOCOL_UNSTRUCTURED |
See also:
getProxyAddress
public InetAddress getProxyAddress ()
This method was deprecated
in API level 29.
use getProxyAddressAsString()
instead.
Gets the HTTP proxy address configured for the APN. The proxy address might be an IP address
or hostname. This method returns null
if system networking (typically DNS) isn\u2019t
available to resolve a hostname value\u2014values set as IP addresses don\u2019t have this restriction.
This is a known problem and will be addressed in a future release.
Returns | |
---|---|
InetAddress |
the HTTP proxy address or null if DNS isn\u2019t available to resolve a hostname |
getProxyAddressAsString
public String getProxyAddressAsString ()
Returns the proxy address of the APN.
Returns | |
---|---|
String |
proxy address. |
getProxyPort
public int getProxyPort ()
Returns the proxy address of the APN.
Returns | |
---|---|
int |
proxy address. |
getRoamingProtocol
public int getRoamingProtocol ()
Returns the protocol to use to connect to this APN while the device is roaming.
Roaming protocol is one of the PDP_type
values in TS 27.007 section 10.1.1.
Returns | |
---|---|
int |
the roaming protocol
Value is PROTOCOL_IP , PROTOCOL_IPV6 , PROTOCOL_IPV4V6 , PROTOCOL_PPP , PROTOCOL_NON_IP , or PROTOCOL_UNSTRUCTURED |
getUser
public String getUser ()
Returns the APN username of the APN.
Returns | |
---|---|
String |
APN username |
hashCode
public int hashCode ()
Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
HashMap
.
The general contract of hashCode
is:
- Whenever it is invoked on the same object more than once during
an execution of a Java application, the
hashCode
method must consistently return the same integer, provided no information used inequals
comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application. - If two objects are equal according to the
equals
method, then calling thehashCode
method on each of the two objects must produce the same integer result. - It is not required that if two objects are unequal
according to the
equals
method, then calling thehashCode
method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns | |
---|---|
int |
a hash code value for this object. |
isAlwaysOn
public boolean isAlwaysOn ()
Returns whether User Plane resources have to be activated during every transition from CM-IDLE mode to CM-CONNECTED state for this APN See 3GPP TS 23.501 section 5.6.13
Returns | |
---|---|
boolean |
True if the PDU session for this APN should always be on and false otherwise |
isEnabled
public boolean isEnabled ()
Returns the current status of APN.
true
: enabled APN.
false
: disabled APN.
Returns | |
---|---|
boolean |
the current status |
isPersistent
public boolean isPersistent ()
Returns if the APN setting is persistent on the modem.
Returns | |
---|---|
boolean |
true if the APN setting is persistent on the modem. |
writeToParcel
public void writeToParcel (Parcel dest, int flags)
Flatten this object in to a Parcel.
Parameters | |
---|---|
dest |
Parcel : This value cannot be null . |
flags |
int : Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE .
Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE , and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-12-18 UTC.