Mar 02

Recently I had some connection issues with Blackberry Java apps and started investigating how to solve this in a good manner. Blackberry have a special way of handling different network and transport types and this needs to be handled by your app.

To begin with I just created a HttpConnection with the plain URL. While doing so you leave it up to the Blackberry device to try to use its’ default connection. This will work in some situations, but quite often you will see that some Blackberry devices will fail creating the HttpConnection. The solution I describe in this post will check for available network/transport types and add some properties to the URL depending on these. Typically Blackberry will use parameters like deviceside=true etc.

Since Blackberry and connectivity is not my strongest expertise I started the investigation by posting a question to the Blackberry Java Development forum. To begin with I believed this was a problem with Blackberry OS 7 but I later found that it was a more general problem. The forum at Blackberry really blew me away. In matter of minutes I got very detailed and competent answers to my question. I send my regards and a big thank you to the helpful persons at the Blackberry developer forum.

You can view the post with my question at the forum: Connecting to network (HttpConnection) with BB OS 7 devices

The first thing I had to do was to get some code to check what network/transport types were available for the device and then add the correct parameters to the URL before creating the HttpConnection. Luckily the code for this is already available in the article: What Is – Network API alternative for legacy OS

I want to also support Blackberry Device Software earlier then 5.0 and for that the Network API alternative for legacy OS suits me very well. I downloaded the file which contains and, these two files I used directly in my project.

Then it is just to use this and check for the transport types you want to support before creating the connection.

String gatewayURL = ""; 
TransportDetective td = new TransportDetective(); 
URLFactory urlFactory = new URLFactory(gatewayURL); 

  //Use MDS if available 
  gatewayURL = urlFactory.getHttpWap2Url(td.getSrMds()); 
} else if(td.isCoverageAvailable(TransportDetective.TRANS<wbr>PORT_TCP_WIFI)){  
  //Use TCP WIFI if available 
  gatewayURL = urlFactory.getHttpWap2Url(td.getTcpWiFiServiceReco<wbr>rd()); 
} else if (td.isDefaultTcpCellularServiceRecordAvailable()){  
  //Use default TCP Celluar Service if available (APN) 
  gatewayURL = urlFactory.getHttpWap2Url(td.getDefaultTcpCellular<wbr>ServiceRecord()); 
} else if(td.isCoverageAvailable(TransportDetective.TRANS<wbr>PORT_WAP2)){ 
  //Use WAP 2 if available 
  gatewayURL = urlFactory.getHttpWap2Url(td.getWap2ServiceRecord(<wbr>)); 
} else if(td.isCoverageAvailable(TransportDetective.TRANS<wbr>PORT_WAP)){ 
  //Use WAP 1 if available 
  gatewayURL = urlFactory.getHttpWap2Url(td.getWapServiceRecord()<wbr>); 

As you see from the code above I do not check for or use BIS-B. The experts at the Blackberry forum recommends adding BIS support but I have skipped that step for now since you then need to use the Blackberry Push Messaging system.

I hope this post will help you a bit on the way if you get some of the same issues as I did.

Follow me on twitter @PerOla

Share & enjoy
You can subscribe to my comments feed to keep track of new comments.

4 Comments to “Connection and transport types for Blackberry Java development”

  1. BlackBerry world has many apps for their devices, for example, BlackBerry PlayBook App known as TEK-Dictionary which i just came across while surfing the apps for my PlayBook. There has been lots of java development for BlackBerry Applications that needs them to run smoothly. I think that java development plays a major part in developing apps.

  2. MMK says:

    Ur post is amazing . thanks it should help me . These issues happen because blackbeery OS is so stupid and inefficient . The programmers at blackberry are morons. why is blackberry development so hard as compared to IOS and Android . A bunch of assholes waiting for the company to dissolve . Blackberry is going down , going down going down . and i hope it does . Get rid of these fucking stupid frameworks . Because if one app works on OS it will not work on other os’s .And there are so many versions of one OS .Common balckbery u suckers try to standardise and improvise stuuff rather than expecting developers to write and erase and write coode again and agian .Fuck u Blackberry . And thanks my man Per Ola sather . thanks for this. But blackberry , u whether u release bb10 or not its not going to help . U will go down the food chain ,oops i mean the competition . and u will diminish because u are hardly competitive . U r a bunch of pathetic egoistic fools .

  3. Alex says:

    Sorry for my English. I have similar problem with BB 7 OS as your question at the forum, but I haven’t solution. My code works on all devices and simulators with BB 7 OS only when wifi – on. I used NetworkAPIAlternative, but it not didn’t help. I tried to use BrowserField.requesContent(url) method, but it didn’t work too. If you found a solution, could you please share it in detail? I would be very grateful.

  4. Patience says:

    ElaiebathJznuary 20, 2012Two more quick things: is it possible to change the color of a blog post title to match the assigned color-based category?And, will you help me find the code that assigns the roll-over color of the categories?You are wonderful for being so helpful!

No Pingbacks to “Connection and transport types for Blackberry Java development”

Leave a Reply

Subscribe to my comments feed

Subscribe to my feeds Follow me on Twitter