Add APN API

Requirement:

  • Insert SIM card first

  • The MCC, MNC should be the same as SIM card inserted

Permission

The application declares the following permissions in the manifest:

 com.wizarpos.permission.WRITE_APN_SETTINGS

API Overview

AddByAllArgs

String addByAllArgs(String name, String apn, String mcc, String mnc, String proxy, String port, String MMSProxy, String MMSPort, String userName, String server, String password, String MMSC, String authType, String protocol, String roamingProtocol, String type, String bearer, String MVNOType, String MVNOMatchData);

Add an APN setting. All paramers can not be set to Null.

Parameters
Value

name

the name of the APN setting. It can not be null or "".

apn

the apn of the APN setting. It can not be null or "".

mcc

the mcc of the APN setting. It can not be null or "".

mnc

the mnc of the APN setting. It can not be null or "".

proxy

the proxy of the APN setting. It can not be null, but can be "".

port

the port of the APN setting. It can not be null, but can be "".

MMSProxy

the MMSProxy of the APN setting. It can not be null, but can be "".

MMSPort

the MMSPort of the APN setting. It can not be null, but can be "".

userName

the userName of the APN setting. It can not be null, but can be "".

server

the server of the APN setting. It can not be null, but can be "".

password

the password of the APN setting. It can not be null, but can be "".

MMSC

the MMSC of the APN setting. It can not be null, but can be "".

authType

the authType of the APN setting. It can not be null or "", but can be "-1", PAP, CHAP, PAP/CHAP.

protocol

the protocol of the APN setting. It can not be null or "", but can be IP, IPV4, IPV6, IPV4/IPV6.

roamingProtocol

the roamingProtocol of the APN setting. It can not be null or "", but can be IP, IPV4, IPV6, IPV4/IPV6.

type

the type of the APN setting. It can not be null, but can be "".

bearer

the bearer of the APN setting. It can not be null or "", but can be "0", LTE, eHRPD.

MVNOType

the MVNOType of the APN setting. It can not be null, but can be "", SPN, IMSI, GID.

MVNOMatchData

the MVNOMatchData of the APN setting. It can not be null, but can be "".

Returns

String

a string representation of the result.

"succeed" if success.

"error description" if failure.

Add

String add(String name, String apn);
Parameters

name

the name of the APN setting. It can not be null or "".

apn

the apn of the APN setting. It can not be null or "".

Returns

String

a string representation of the result.

"succeed" if success.

"error description" if failure.

AddByMCCAndMNC

String addByMCCAndMNC(String name, String apn, String mcc, String mnc);

Add an APN setting.

Parameters

name

the name of the APN setting. It can not be null or "".

apn

the apn of the APN setting. It can not be null or "".

mcc

the mcc of the APN setting. It can not be null or "".

mnc

the mnc of the APN setting. It can not be null or "".

Returns

String

a string representation of the result.

"succeed" if success.

"error description" if failure.

SetSelected

boolean setSelected(String name);

Set default APN.

Parameters

name

the name of the APN setting. It can not be null or "".

Returns

boolean

a boolean representation of the result.

true if success. false if failure.

getSelected()

Map getSelected();

Get detail information of the selected APN.

Returns

Map

a map representation of the result. Detail information map of the selected APN.

Snippet code:

ApnDevice apnDevice=...;
apnDevice.open();
HashMap res = (HashMap)apnDevice.getSelected();
StringBuilder sb = new StringBuilder();
if (res != null) {
sb.append(Telephony.Carriers.NAME + ": ").append(res.get(Telephony.Carriers.NAME) + "\n")
.append(Telephony.Carriers.APN + ": ").append(res.get(Telephony.Carriers.APN) + "\n")
.append(Telephony.Carriers.PROXY + ": ").append(res.get(Telephony.Carriers.PROXY) + "\n")
.append(Telephony.Carriers.PORT + ": ").append(res.get(Telephony.Carriers.PORT) + "\n")
.append(Telephony.Carriers.MMSPROXY + ": ").append(res.get(Telephony.Carriers.MMSPROXY) + "\n")
.append(Telephony.Carriers.MMSPORT + ": ").append(res.get(Telephony.Carriers.MMSPORT) + "\n")
.append(Telephony.Carriers.USER + ": ").append(res.get(Telephony.Carriers.USER) + "\n")
.append(Telephony.Carriers.SERVER + ": ").append(res.get(Telephony.Carriers.SERVER) + "\n")
.append(Telephony.Carriers.MMSC + ": ").append(res.get(Telephony.Carriers.MMSC) + "\n")
.append(Telephony.Carriers.AUTH_TYPE + ": ").append(res.get(Telephony.Carriers.AUTH_TYPE) + "\n")
.append(Telephony.Carriers.PROTOCOL + ": ").append(String.valueOf(res.get(Telephony.Carriers.PROTOCOL)) + "\n")
.append(Telephony.Carriers.ROAMING_PROTOCOL + ": ").append(String.valueOf(res.get(Telephony.Carriers.ROAMING_PROTOCOL)) + "\n")
.append(Telephony.Carriers.TYPE + ": ").append(res.get(Telephony.Carriers.TYPE) + "\n")
.append(Telephony.Carriers.MCC + ": ").append(res.get(Telephony.Carriers.MCC) + "\n")
.append(Telephony.Carriers.MNC + ": ").append(res.get(Telephony.Carriers.MNC) + "\n")
.append(Telephony.Carriers.BEARER + ": ").append(res.get(Telephony.Carriers.BEARER) + "\n")
.append("mvno_type: ").append(String.valueOf(res.get("mvno_type")).toUpperCase() + "\n")
.append("mvno_match_data: ").append(res.get("mvno_match_data"));
}
apnDevice.close();

Clear

boolean clear();

Clear all APN settings.

Returns

boolean

a boolean representation of the result.

true if success. false if failure.

Clear APN of one slot

boolean clearWithSlot(int slot);

Clear APN of one slot.

Parameters

slot

the slot of the APN

Returns

boolean

a boolean representation of the result.

true if success. false if failure.

Query

List query(String name,String value);

Query by name and value.

Parameters

name

the name of the APN setting. It can not be null or "".

value

Returns

List

Query

boolean queryByName(String name);

Query by name.

Parameters

name

.

Returns

List

Resource Download

  • Refer to the cloudpos apidemo - demo.

Last updated