Currently, I work for China Telecom and only work for China Telecom. Therefore, the list only contains China Telecom's APN information.
Java code
/**
* China Telecom APN list
* @ Author wudongdong
*
*/
Public class apnnet {
Public static string ctwap = "ctwap ";
Public static string ctnet = "ctnet ";
}
/**
* China Telecom APN list
* @ Author wudongdong
*
*/
Public class apnnet {
Public static string ctwap = "ctwap ";
Public static string ctnet = "ctnet ";
} Obtain the APN type
Java code
/**
* Obtain the APN type
* @ Author wudongdong
*
*/
Public class apnutil {
Private Static URI preferred_apn_uri = URI
. Parse ("content: // telephony/carriers/preferapn ");
/**
* Get apntype
* @ Param Context
* @ Return
*/
Public static string getapntype (context ){
String apntype = "nomatch ";
Cursor c = context. getcontentresolver (). Query (preferred_apn_uri,
Null, null );
C. movetofirst ();
String user = C. getstring (C. getcolumnindex ("user "));
If (user. startswith (apnnet. ctnet )){
Apntype = apnnet. ctnet;
} Else if (user. startswith (apnnet. ctwap )){
Apntype = apnnet. ctwap;
}
Return apntype;
}
}
/**
* Obtain the APN type
* @ Author wudongdong
*
*/
Public class apnutil {
Private Static URI preferred_apn_uri = URI
. Parse ("content: // telephony/carriers/preferapn ");
/**
* Get apntype
* @ Param Context
* @ Return
*/
Public static string getapntype (context ){
String apntype = "nomatch ";
Cursor c = context. getcontentresolver (). Query (preferred_apn_uri,
Null, null );
C. movetofirst ();
String user = C. getstring (C. getcolumnindex ("user "));
If (user. startswith (apnnet. ctnet )){
Apntype = apnnet. ctnet;
} Else if (user. startswith (apnnet. ctwap )){
Apntype = apnnet. ctwap;
}
Return apntype;
}
}
If you obtain the mobile phone number, you can transmit the imsi code to the specified interface. The interface address is not convenient.
However, it can be disclosed that ctwap is required, which is also the reason for determining the APN type.
If you find that many applications cannot connect to the Internet if you use an APN proxy, let's introduce the network proxy information configured with the APN.
Java code
Cursor c = context. getcontentresolver (). Query (preferred_apn_uri,
Null, null );
C. movetofirst ();
String proxy = C. getstring (C. getcolumnindex ("proxy "));
If (! "". Equals (proxy) & proxy! = NULL ){
Properties prop = system. getproperties ();
System. getproperties (). Put ("proxyset", "true ");
Prop. setproperty ("HTTP. proxyhost", C. getstring (C
. Getcolumnindex ("proxy ")));
Prop. setproperty ("HTTP. proxyport", C. getstring (C
. Getcolumnindex ("Port ")));
String authentication = C. getstring (C. getcolumnindex ("user "))
+ ":" + C. getstring (C. getcolumnindex ("password "));
String encodedlogin = base64.encode (authentication );
UC. setrequestproperty ("proxy-Authorization", "Basic"
+ Encodedlogin );
}
C. Close ();