Would you like to tell us how we are doing?

You bet No thanks

Sorry about the red box, but we really need you to update your browser. Read this excellent article if you're wondering why we are no longer supporting this browser version. Go to Browse Happy for browser suggestions and how to update.

Networking

Networking and connectivity

A BlackBerry smartphone uses radio communication technologies such as CDMA, GPRS, and Wi-Fi technology to communicate over wireless connections. BlackBerry smartphones work with different network transports over those radio technologies to connect to the Internet or a private network. Each transport offers different advantages. As a developer, you should choose the transport that is most appropriate for your requirements.

When you choose a transport for your app, you should consider a number of factors, including:
  • Type of user
  • Importance of security and reliability
  • Networks that the app must use and support for roaming users
  • Amount of data that you expect to send and receive
  • Need to proactively push data for updates and alerts
  • Location of the destination server (Internet or intranet)

You can open a network connection using the following APIs:

API

Description

BlackBerry Device Software version

Network API

The Network API provides a simple interface to access many connection-related options and network transports.

5.0 and later

Generic Connection Framework

The GCF provides a flexible way to create network connections using the transport of your choice.

4.0 and later

Communication API

The Communication API encapsulates all the operations that are required to connect to an HTTP server that is located on the Internet or behind an organization's firewall.

6.0 and later

The BlackBerry solution also enables server-side apps to proactively push data to BlackBerry smartphones in a highly secure and reliable manner.

You can also use technologies such as Bluetooth to communicate with accessories, and NFC to communicate with smart tags.

Network connections

The BlackBerry Java SDK offers two APIs that you can use to create network connections manually: the Network API and the GCF. Apps that target smartphones running BlackBerry Device Software 5.0 and later can use the Network API. The Network API provides a simple interface for working with network transports, and setting a wide variety of parameters for a connection. You can use the GCF to create network connections on smartphones that run previous versions of the BlackBerry Device Software. However, using the GCF requires knowledge of more BlackBerry APIs to discover what transports are available and how to configure them.

Regardless of which API you choose, the process of creating a network connection is similar. First open a network connection, then read and write data over that connection, and finally close the connection. Before you open a connection, you usually specify a transport, a protocol, and an end point. You can connect to network resources using a wide range of protocols. However, you should be aware that not all transports support all protocols. For example, WAP 1.0 and 1.1 only support HTTP over WAP and HTTPS over WAP or WTLS. The BlackBerry Application Platform supports the following protocols:

  • HTTP
  • HTTPS
  • Socket
  • TLS
  • SSL
  • UDP (Datagram)

The protocol and the end point are determined by your app, but the transport is determined by your users' operating environment. You may need to try more than one transport before you can make a successful connection. The following table suggests preference orders for consumer and enterprise apps that target users on CDMA and GPRS wireless networks:

CDMA

GPRS

Consumer

  1. TCP Wi-Fi
  2. TCP Cellular
  3. BlackBerry Internet Service
  4. WAP 2.0
  5. BlackBerry Mobile Data System
  1. TCP Wi-Fi
  2. BlackBerry Internet Service
  3. WAP 2.0
  4. BlackBerry Mobile Data System
  5. TCP Cellular

Enterprise

  1. BlackBerry MDS
  2. TCP Wi-Fi
  3. TCP Cellular
  4. BlackBerry Internet Service
  5. WAP 2.0
  1. BlackBerry MDS
  2. TCP Wi-Fi
  3. BlackBerry Internet Service
  4. WAP 2.0
  5. TCP Cellular

After you open a connection, you receive a Connection object that represents your connection. The javax.microedition.io package contains several interfaces that you can use to manipulate a Connection object.

Interface

Description

HttpConnection

This interface provides methods to set the HTTP request method (GET, POST, and so on) and headers, and send and receive data over the connection.

HttpsConnection

This interface includes all of the methods in the HttpConnection interface, and adds getSecurityInfo() that returns the certificate that is supplied by the web server.

SocketConnection

This interface exposes methods to send data to and receive data from a network host over a socket connection.

SecureConnection

This interface provides methods to create TLS and SSL socket connections. This interface includes all of the methods in the SocketConnection interface, and adds getSecurityInfo() that returns security information about the connection.

UDPDatagramConnection

This interface provides methods to retrieve information about the connection, and create new datagram objects.

InputConnection, OutputConnection

These interfaces provide access to a connection's input and output data streams.

When you are ready to use your connection, cast the Connection object according to the protocol that you used to open the connection. You will need the InputConnection and OutputConnection interfaces from the javax.microedition.io package to access the Connection object's send and receive functions. Those interfaces expose the Connection object's input and output streams. For more information about sending data over the connection, see the InputStream and OutputStream classes in the API reference for the BlackBerry Java SDK.

Architecture: Network transports

A BlackBerry smartphone can connect to a wireless network by using different transports. Not all smartphones have access to all transports. For example, the BlackBerry Mobile Data System transport is only available to smartphones registered with a BlackBerry Enterprise Server.

An architecture diagram illustrating the different network transports that the BlackBerry smartphone can connect to.

Network transport

Description

TCP Wi-Fi

The Wi-Fi transport creates a connection to the Internet, or to private networks such as those in an organization or home. When the Wi-Fi radio is turned on, a smartphone user or an app can configure the smartphone to connect to the Internet using this transport.

If there are multiple transport services available, a smartphone running BlackBerry 6 or later automatically sends data using the fastest data connection. Earlier versions of BlackBerry Device Software send data through the least expensive transport, rather than the fastest.

TCP Cellular

The TCP Cellular transport creates a connection to the Internet through a wireless service provider's Internet gateway. This method creates the most direct type of connection that uses the cellular radio.

Most wireless service providers configure a user's BlackBerry smartphone to use the provider's Internet gateway. However, when the user roams on a different network, the user needs to configure the smartphone manually to use the Internet gateway on the host network.

If your app uses this transport, you should test it for each wireless service provider that your app might use.

BlackBerry Internet Service

The BlackBerry Internet Service transport creates a connection to the Internet through the BlackBerry Infrastructure. Data that you send and receive using this transport is compressed and optimized for transmission over wireless connections.

To use the BlackBerry Internet Service transport, you must sign up for the Push Service. For more information, visit http://developer.blackberry.com/devzone/develop/platform_services/push_overview.html

BlackBerry MDS

The BlackBerry MDS transport enables a BlackBerry smartphone to connect to its associated BlackBerry Enterprise Server through the BlackBerry Infrastructure or using a Wi-Fi connection.

WAP

The WAP transport creates a connection through a wireless service provider's WAP gateway. WAP 1.0, 1.2, and 2.0 are supported.

To support this transport, a user or wireless service provider must configure the WAP connection parameters on the smartphone. As a result, this transport might not be supported on all wireless networks or with all data plans.

If your app uses this transport, you should test it for each wireless service provider that your app might use. For more information, see "Using a wireless service provider's Internet gateway".

To use WAP 2.0, you will need to retrieve the connection ID from the service book. For more information about retrieving a connection ID, see the knowledge base article at http://supportforums.blackberry.com/t5/Java-Development/What-Is-Network-API-alternative-for-legacy-OS/ta-p/614822