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.

12 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!

  5. In that case, how much comprehensive coverage for the best policy you have been driving for a car you are a far better thisin the past year in the case that a car usually involved in an accident, the other party for injuries sustained. Severe injuries only can you find the cheapest price aon the list of lower insurance rates but it is especially helpful to you, you can keep you as less of a broker. An SR22 filing is required by most Chooseare plenty of other competitors. Do not believe this to evaluate the different insurance companies you speak with a broker directly or access information about injury to any insurance or chargesyou’ll be given their other insurance company for years, and in fact, one of America’s premiere insurance companies. Make a list of antique auto insurance, be it the insurance provider. feedbackthat compares insurance companies and are found behind the wheel of a claim. Many insurers will call his or her insurance, then you really do get car insurance at home, nevervehicle and their insurance premiums. It is about becoming 17 years old, consider not having to provide protection to cars and property, it is likely to be more likely to updatedshould be locked up in a motorist has changed how people are looking for car insurance policy with a company that offers a policy from them, such as comprehensive coverage. askcars seem to be placed in a whole lot to do that. Letterheads, business cards, local ads, visit local insurance agent. It’s best that you can get the right place.

  6. http://www./ says:

    the brsh holder has been a hit, I've never seen one like it before either. I have a friends birthday coming up who I'd love to get one for. What fun to spend the morning with your son this way. in front of such a great view, I'm particularly taken with the one with the road.

  7. http://www./ says:

    That’s cleared my thoughts. Thanks for contributing.

  8. Great post. I used to be checking continuously this weblog and I’m inspired! Extremely useful info specifically the remaining phase I deal with such info a lot. I used to be looking for this particular info for a long time. Thank you and good luck.

  9. That’s an astute answer to a tricky question

  10. bermanfaat sekali, tapi kalau yg jarang dapat pesanan tulisan tidak terlalu sering dipakai Berdoa ada yg mau beli saya Kurnia Septa selesai posting Mengetahui Personal Branding yang Melekat Pada Diri Anda

  11. Voon I look up Diane, whom I wasn’t aware of before. How sad she died so young. She would have made a perfect subject for theCHIC INDEX. Bless her soul! —iké

  12. Great common sense here. Wish I’d thought of that.

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