Monday, September 21, 2009

Run BlackBerry Application without APN -Dynamically add APN from XML file

Most time we need to connect internet and use web services without setting apn.Some times user may use different sim cards and different service providers but application must work with them all without changing

In this dialog box we will display web page content of given url.Here getpage() method and getTag() methods are in my blog so simply you can  use them

String mcc = Integer.toHexString(RadioInfo.getMCC  (RadioInfo.getCurrentNetworkIndex()));
String mnc = Integer.toHexString(RadioInfo.getMNC(RadioInfo.getCurrentNetworkIndex())); Dialog.alert(getTag(ReadFile(),mcc+","+mnc));
Dialog.alert(getPage(""+";deviceside=true;apn="+getTag(ReadFile(),mcc+","+mnc)));//Dialog will display web page content

//New URL is= (""+";deviceside=true;apn="+getTag(ReadFile(),mcc+","+mnc))


ReadFile Method

public String ReadFile()
//This retturns the String in FileName.txt
//File must locate in Src Folder
try {
Class classs = Class.forName("pkgName.className");//Replace package name and class name with your parameters
//Source Package neme and Class name
InputStream is = classs.getResourceAsStream("/test.txt");//test.txt add to your package folder
byte[] data = new byte[is.available()];, 0, is.available());
String c =new String(data);
return c;
catch (Exception ioe)
return null;



This File provides apn according to the values of mcc and mnc

<310,4></<310,4> verizon
<310,38></310,38>     AT&T

1 comment: