Share via


DevicePolicyManager.AddOverrideApn(ComponentName, ApnSetting) Method

Definition

Called by device owner or managed profile owner to add an override APN.

[Android.Runtime.Register("addOverrideApn", "(Landroid/content/ComponentName;Landroid/telephony/data/ApnSetting;)I", "GetAddOverrideApn_Landroid_content_ComponentName_Landroid_telephony_data_ApnSetting_Handler", ApiSince=28)]
public virtual int AddOverrideApn (Android.Content.ComponentName admin, Android.Telephony.Data.ApnSetting apnSetting);
[<Android.Runtime.Register("addOverrideApn", "(Landroid/content/ComponentName;Landroid/telephony/data/ApnSetting;)I", "GetAddOverrideApn_Landroid_content_ComponentName_Landroid_telephony_data_ApnSetting_Handler", ApiSince=28)>]
abstract member AddOverrideApn : Android.Content.ComponentName * Android.Telephony.Data.ApnSetting -> int
override this.AddOverrideApn : Android.Content.ComponentName * Android.Telephony.Data.ApnSetting -> int

Parameters

admin
ComponentName

which DeviceAdminReceiver this request is associated with

apnSetting
ApnSetting

the override APN to insert

Returns

The id of inserted override APN. Or -1 when failed to insert into the database.

Attributes

Remarks

Called by device owner or managed profile owner to add an override APN.

This method may returns -1 if apnSetting conflicts with an existing override APN. Update the existing conflicted APN with #updateOverrideApn(ComponentName, int, ApnSetting) instead of adding a new entry.

Two override APNs are considered to conflict when all the following APIs return the same values on both override APNs: <ul> <li>ApnSetting#getOperatorNumeric()</li> <li>ApnSetting#getApnName()</li> <li>ApnSetting#getProxyAddressAsString()</li> <li>ApnSetting#getProxyPort()</li> <li>ApnSetting#getMmsProxyAddressAsString()</li> <li>ApnSetting#getMmsProxyPort()</li> <li>ApnSetting#getMmsc()</li> <li>ApnSetting#isEnabled()</li> <li>ApnSetting#getMvnoType()</li> <li>ApnSetting#getProtocol()</li> <li>ApnSetting#getRoamingProtocol()</li> </ul>

Before Android version android.os.Build.VERSION_CODES#TIRAMISU: Only device owners can add APNs.

Starting from Android version android.os.Build.VERSION_CODES#TIRAMISU: Both device owners and managed profile owners can add enterprise APNs (ApnSetting#TYPE_ENTERPRISE), while only device owners can add other type of APNs. Enterprise APNs are specific to the managed profile and do not override any user-configured VPNs. They are prerequisites for enabling preferential network service on the managed profile on 4G networks (#setPreferentialNetworkServiceConfigs).

Java documentation for android.app.admin.DevicePolicyManager.addOverrideApn(android.content.ComponentName, android.telephony.data.ApnSetting).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to