Welcome!

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

Determine when to route data

by Retired on ‎02-17-2010 12:57 PM - edited on ‎11-22-2010 07:29 PM by (2,830 Views)

Summary

 

This article applies to the following:

  • BlackBerry® Device Software 4.1 and later
  • BlackBerry API Set 4.1 and later

Description

 

With the release of the ServiceBook application programming interface (API) in BlackBerry® Java® Development Environment (BlackBerry JDE) 4.0 and the ServiceRouting API in BlackBerry JDE 4.1, there are several new tools to help developers determine when the BlackBerry smartphone is able to route data optimally. In the case of many applications, developers check the radio status of the BlackBerry smartphone to determine if the radio is off before attempting to connect to the network. The rationale behind checking the network is that the Connector.open call will require a two minute timeout even if the radio has been turned off. It is best for the application to check the radio status before invoking Connector.open.

 

With the ServiceRouting API introduced in BlackBerry JDE 4.1, a strict check of the radio status is no longer sufficient for determining when to route data over an Internet Protocol Proxy Protocol (IPPP) service book. For more information on how to use the Service Routing API, see this article. With only a few lines of code, an application can determine whether the ServiceRecord is currently routable and can be used by the application. A sample method called isDataRoutable is provided below showing how to determine if a service is routable given the current APIs.

 

The serviceUID refers to the UID provided as part of the ServiceBook API defining which ServiceRecord to use for the transportation.

 

 

public boolean isDataRoutable( String serviceUID )
{
if( ServiceBook.getSB().getRecordByUidAndCid( serviceUID, "IPPP" ) == null ) {
// There is no service book
return false;
}
if( ServiceRouting.getInstance().isSerialBypassActive (serviceUID) ) {
// Serial bypass is active
return true;
}
// Make sure the radio is on and there is data coverage

if ((RadioInfo.getState() != RadioInfo.STATE_OFF && ( RadioInfo.getNetworkService() & RadioInfo.NETWORK_SERVICE_DATA ) != 0) && CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_MDS) {

return true;
}

else

{

return false;

}

 

 

Contributors
Users Online
Currently online: 20 members 1,102 guests
Please welcome our newest community members: