After some searching on the net I found one way to achieve this is by identifying the mobile network and then setting the connection properties appropriately.
The steps involved is as follows.
Step 1
Identify the network the phone is currently in.
If you need help on this go to this URL.
Step 2
Get the APN settings for your network.
The way here is to have a file with all the settings of different wireless service providers you intend to run your application on, and then compare the value returned from Step 1 and get to the particular APN.
I suggest you to keep a XML or text file with the following details of the service provider,
- Country Name
- MCC
- Carrier Name
- MNC
- TCPAPN
- TCPAPNUserName
- TCPAPNPassword
- WAPAPN
- WAPIP
- WAPPort
- WAPUserName
- WAPPassword
- WAPSourceIP
- WAPSourcePort
- IsEnableWTLS
Add the APN to the connection.
If you need help on this go to this URL.