- 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.