Architecture: Network transports

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

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 BlackBerry® device user or an application can configure the device to connect to the Internet using this transport.

If there are multiple transport services available, a device 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 device to use the provider's Internet gateway. However, when the user roams on a different network, the user needs to configure the device manually to use the Internet gateway on the host network.

If your application uses this transport, you should test it for each wireless service provider that your application 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.

Note: To use the BlackBerry Internet Service transport, you must sign up for the Push Service. For more information, visit www.blackberry.com/developers/pushservice

BlackBerry MDS

The BlackBerry MDS transport enables a BlackBerry device 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 device. As a result, this transport might not be supported on all wireless networks or with all data plans.

If your application uses this transport, you should test it for each wireless service provider that your application 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

Code sample: Determining network transports with sufficient coverage using the Network API

import net.rim.device.api.io.transport.*;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;

public class NetworkSample extends UiApplication 
{
    public static void main(String[] args) 
    {
        NetworkSample app = new NetworkSample();
        app.enterEventDispatcher();
    }
    public NetworkSample() {
        pushScreen(new ListTransportsWithCoverageScreen());
    }
}


class ListTransportsWithCoverageScreen extends MainScreen
{

    private int[] _transportsWithCoverage;
    private TransportDescriptor[] _transports;
    private RichTextField _rtfDisplay;
    private ButtonField _btnShowTransports;

    public ListTransportsWithCoverageScreen()
    {
        VerticalFieldManager vfm = new VerticalFieldManager();
        setTitle("Network Sample");
        _rtfDisplay = new RichTextField
             ("Click button below to display available transports.");
        _btnShowTransports = new ButtonField
             ("Show Transports", Field.FIELD_HCENTER);
        _btnShowTransports.setChangeListener(new FieldChangeListener()
        {
            public void fieldChanged(Field field, int context)
            {
                getTransports();
            }
        });
        vfm.add(_rtfDisplay);
        vfm.add(_btnShowTransports);
        add(vfm);

    }

    public void getTransports()
    {
        StringBuffer sb = new StringBuffer();
        sb.append("The transports currently available are: \n");
        _transportsWithCoverage = TransportInfo.getCoverageStatus();
        _transports = TransportInfo.getTransportDescriptors
                          (_transportsWithCoverage);
        for(int i = _transports.length - 1; i >=0; --i)
        {
            switch(_transports[i].getTransportType())
            {
            case TransportInfo.TRANSPORT_BIS_B:
                sb.append("BlackBerry Internet Service\n");
                break;
            case TransportInfo.TRANSPORT_MDS:
                sb.append("BlackBerry Mobile Data Service\n");
                break;
            case TransportInfo.TRANSPORT_TCP_CELLULAR:
                sb.append("TCP Cellular\n");
                break;
            case TransportInfo.TRANSPORT_TCP_WIFI:
                sb.append("TCP WiFi\n");
                break;
            case TransportInfo.TRANSPORT_WAP:
                sb.append("WAP 1.0 or 1.1\n");
                break;
            case TransportInfo.TRANSPORT_WAP2:
                sb.append("WAP 2.0\n");
                break;
           }
        }
        _rtfDisplay.setText(sb.toString());
    }
}
Back To Top

Code sample: Determining the status of a network transport using the Network API

import net.rim.device.api.io.transport.TransportInfo;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;


public class NetworkSample extends UiApplication 
{
    public static void main(String[] args) 
    {
        NetworkSample app = new NetworkSample();
        app.enterEventDispatcher();
    }
    public NetworkSample() 
    {
        pushScreen(new ProbeSpecificTransportScreen());
    }
}

class ProbeSpecificTransportScreen extends MainScreen implements FieldChangeListener {

    private TextField _tfTransportStatus;
    private ObjectChoiceField _ocfTransports;

    public ProbeSpecificTransportScreen()
    {
        String[] strTransportNames = 
        {"none", "TCP Cellular", "WAP 1.0/1.1", 
         "WAP 2.0", "MDS", "BIS", "TCP WiFi"
        };

        VerticalFieldManager vfm = new VerticalFieldManager();

        _tfTransportStatus = new TextField(Field.FIELD_HCENTER);
        _tfTransportStatus.setText
            ("Select a transport from the list above, then click 'Probe Transport'");

        _ocfTransports = new ObjectChoiceField
            ("Select Transport to Probe: ", strTransportNames, 
                 0, Field.FIELD_HCENTER);
        _ocfTransports.setEditable(true);

        ButtonField btnProbe = new ButtonField("Probe Transport", Field.FIELD_HCENTER);
        btnProbe.setChangeListener(this);

        vfm.add(_ocfTransports);
        vfm.add(btnProbe);
        vfm.add(_tfTransportStatus);
        add(vfm);
    }

    public void fieldChanged(Field field, int context)
    {
        int intTransportType = _ocfTransports.getSelectedIndex();
        if(intTransportType > 0)
        {
            if(TransportInfo.isTransportTypeAvailable(intTransportType))
            {
                if(TransportInfo.hasSufficientCoverage(intTransportType))
                {
                    _tfTransportStatus.setText
                         ((String)_ocfTransports.getChoice(intTransportType) 
                             + " is available.");
                } else
                {
                    _tfTransportStatus.setText
                         ((String)_ocfTransports.getChoice(intTransportType) 
                             + " is available but has insufficient coverage.");
                }
            } else
            {
                _tfTransportStatus.setText("Sorry, " + 
                     (String)_ocfTransports.getChoice(intTransportType) 
                         + " is not available.");

            }
        } else
        {
            _tfTransportStatus.setText
                ("Please select a transport first, then click 'Probe Transport'");

        }
    }


}
Back To Top
Next topic: The Network API
Previous topic: Network connections

Was this information helpful? Send us your comments.