Problem:
Creating an http connection across all carriers / networks / services (BIS, BES, TCP).
BlackBerrys require connection information to be appended to each request. For example, instead of requesting http://www.google.com BlackBerrys need the request to be http://www.google.com;deviceside=true;ConnectionTimeout=20000; The appended string describes how the network will execute the request. The issue is that for BIS services the carrier information must be specified. There are two ways to do this.
- determine apn settings by cross-referencing an application-defined xml file and the carrier.
- intensely search google and find a single magic string --> mds-public
The solution is the following:
private static String getConnectionString()
{
//The Device is a simultaor --> TCP
if (DeviceInfo.isSimulator())
return ";deviceside=true;ConnectionTimeout=20000";
String st = "";
//A carrier is providing us with the data service
if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_CARRIER) == CoverageInfo.COVERAGE_CARRIER)
{
// blackberry internet service
ServiceRecord rec = getBIBSRecord();
if (rec == null)//couldn't find the right record
st = ";deviceside=true";// let the phone try to do the work
else//found the record, get the id
st = ";deviceside=false;connectionUID=" + rec.getUid()
+ ";ConnectionType=mds-public";
}
else if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS)
st = ";deviceside=false";// use the clients blackberry enterprise server
else
st = ";deviceside=true";// let the phone do the work if it can
return st + ";ConnectionTimeout=45000";
}
//gets the record referring to the BIS configuration
private static ServiceRecord getBIBSRecord()
{
ServiceRecord[] ippps = ServiceBook.getSB().getRecords();
for (int i = 0; i < ippps.length; i++)
{
if (ippps[i].getCid().equals("IPPP"))
{
if (ippps[i].getName().indexOf("BIBS") >= 0)
return ippps[i];
}
}
return null;
}
The only thing to note is the connectionUID portion. Basically if you are accessing the mds-public domain you need to specify which one --> connectionUID. Fortunately this ID is identical to the service records UID. So appending all that information gives you access to all the network coverage you need. The only thing not included in this is access to WIFI. Let us know if you tackle this.
This solution was created by Mike Nelson, AccelGolf's lead mobile developer.