• BlackBerry Dynamics
  • Runtime library for Android applications
  • 10.0.0.93
PushConnectionListener Interface Reference

Listener interface for Push Connection state transitions (deprecated). More...

Description

Deprecated:
This class is deprecated and will be removed in a future release. Instead of setting a PushConnection listener, register for notifications as described in the GDNetworkInfo class reference.

Errors and state changes that occur when using PushConnection are handled by creating a class that implements this protocol.

Code Snippets

The following code snippets illustrate some common tasks.

Print State-Change

public class MyConnectionListener implements PushConnectionListener {
public void onStatus(int code) {
if (PushConnection.getInsance().isConnected) {
System.out.println("Connected OK. Push Channel service available.");
} else {
System.out.println("Push Channel service not available.");
}
}
}

The above snippet shows a very simple handler for PushConnection state-change. The availability of the Push Channel service is written to the system log.

Set Event Handler

PushConnection.getInstance().setListener(this);

The above snippet shows how the above handler could be associated with the Push Connection.

Public Member Functions

void onStatus (int status)
 Callback for all status changes. More...
 

Member Function Documentation

◆ onStatus()

void onStatus ( int  status)

The callback is invoked when the Push Connection changes state, or when an error occurs.

The method that is invoked could call isConnected to determine the availability of the following features:

  • Push Channel service
  • Communication through the BlackBerry Dynamics proxy infrastructure

If the features are available (i.e. isConnected returns true), then any of the following actions that were waiting could now proceed:

  • Establishing a Push Channel, see connect
  • Opening a socket connection, or sending an HTTP request, to a server that is behind the enterprise firewall, see the com.good.gd.net package.

If the features are not available (i.e. isConnected returns false) then the method that is invoked could alert the user, or display this as an ongoing state. In this state, Push Channel notifications would not be received.

Parameters
statusInternal numeric code for the new status. Specific values are not documented, and should not be relied upon.

During establishment or termination of the Push Connection with the BlackBerry Dynamics proxy infrastructure, see GDPushConnection connect and disconnect , the callback will be invoked a number of times, as the action progresses.

Events that have an impact on the state of the Push Connection also result in the callback being invoked. This would include loss of network coverage and other losses of data connection, as well as the subsequent automatic re-establishment of the connection.

com.good.gd.push.PushConnectionListener.onStatus
void onStatus(int status)
Callback for all status changes.