Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Networking API

by Retired on ‎07-29-2010 12:25 PM - edited on ‎09-20-2010 05:02 PM by Retired (8,403 Views)



BlackBerry® devices support many different transports that facilitate reliable data communication between third-party applications and the Internet. The transports available are TCP Cellular, BlackBerry® Mobile Data System (BlackBerry MDS), BlackBerry® Internet Service Browsing (BIS-B), Wireless Access Protocol (WAP)1.0, WAP2.0 and Wi-Fi® technology. It is important to understand the differences between these transports and how and when to leverage each transport.


Prior to BlackBerry® Java® Development Environment (BlackBerry JDE) 5.0 it is also crucial to determine if a transport is available for use before trying to use it. The new networking API (net.rim.device.api.io.transport) introduced in BlackBerry JDE 5.0 are designed to simplify the establishment of connections over the different transports available on the BlackBerry device by abstracting away the details of parsing services records and constructing proper URLs for the Connector.open().


In BlackBerry JDE 5.0 the getConnection() method  as part of the ConnectionFactory class allows you to create a connection to the specified URL starting with HTTP, HTTPs, socket, TLS or SSL connections using the first available transport type from the array of preferred transport types if defined, or from the available transport types if no preferences were set.  At the same time it is important to note that this class is not thread-safe and the getConnection() method blocks. This means that you should not call these methods from the main event thread of an application.


The connection factory class provides many features to make setting up network connections easier. Developers can configure preferred transport types by using ConnectionFactory.setPreferredTransportTypes(int[]) or  disallow transport types by using ConnectionFactory.setDisallowedTransportTypes(int[]).


Below example shows how to make a connection from a preference ordered list using the connection factory class in the Network API.



// Make a preference ordered list of transport types

Int[] preferredTransportTypes = {TransportInfo.Transport_MDS,TransportInfo.Transport_WAP2}

ConnectionFactory factory = new ConnectionFactory();


ConnectionDescriptor conDescriptor = factory.getConnection(“http://www.blackberry.com”);

If (conDescriptor !=null) { //connection succeeded

int transportUsed = conDescriptor.getTransportDescriptor().getTransportType();

HttpConnection httpCon (HTTPConnection) conDescriptor.getConnection();


In addition to configuring the preferred transports you can customize the factory by setting specific options to use for the TCP Cellular, WAP, and BIS-B.  Developers can also specify connection timeout settings for WAP, MDS, BIS-B and also enable and listen for connection retry attempts.


For more information on the Network Transport API please refer to the net.rim.device.api.io.transport package.


<!--[if gte mso 10]> <!--[endif]-->
  • BlackBerry® Java® Development Environment (BlackBerry JDE) 5.0 or later
  • BlackBerry® JDE Plug-in for Eclipse® 1.0 or later
  • BlackBerry Device Software 5.0 and higher
Users Online
Currently online: 16 members 528 guests
Please welcome our newest community members: