Showing posts with label APN. Show all posts
Showing posts with label APN. Show all posts

Thursday, September 17, 2009

Setting APN Automatically

If you tried to create a BlackBerry application which uses internet through Direct TCP transport and needed to release it to a set of users who are using different mobile networks you may have had the problem of how you can release the application in a way that users don't have to make any setting changes to make your application get connected. The complexity here happens because different service providers (mobile networks) are using different settings (for example APN).
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
Step 3
Add the APN to the connection.
If you need help on this go to this URL.

Sunday, September 13, 2009

Setting APN

APN or Access Point Name is a setting which needs to be set on the mobile when we need to get connected to internet using the phone.

APN changes from one mobile service provider to the other. For example Dialog will have http://www.dialogsl.com/ Rogers will have internet.com set as their APN.

But letting users set the APN manually is always not the preferred way. Recently we developed an application for BlackBerry which the user needed to get to the internet without he manually setting the APN. The application was supposed to be delivered through BlackBerry App World so manually setting APN was not an option. In a case like this what you have to do is set the APN programmatically into the connection.

String URL = “www.SomeServer.com”;
StringBuffer bfURL;
bfURL = new StringBuffer ();
bfURL.append (URL);
bfURL.append ("
;deviceside=true ;apn=internet.com");
bfURL.append ("
;tunnelauthusername=UserName;tunnelauthpassword=Password");
String FinalURL = bfURL.toString ();

In the above code I have set the Rogers APN in to this connection.

If you need more details on the parameters used or need to know about the other parameters you are eligible to use such as WapGatewayIP, WapGatewayPort, WapGatewayAPN, etc visit the following link to view full details of the connector class.

http://www.blackberry.com/developers/docs/4.2api/javax/microedition/io/Connector.html