• BlackBerry Dynamics
  • Runtime library for Android applications
  • 9.2.0.99
GDNetworkInfo Class Reference

BlackBerry Dynamics infrastructure connection status. More...

Description

This class represents the status of the connection from the application to the BlackBerry Dynamics infrastructure.

Every BlackBerry Dynamics application connects to the BlackBerry Dynamics infrastructure whenever possible. The connection is maintained by the BlackBerry Dynamics runtime instance that is embedded in the application. The infrastructure includes the BlackBerry Dynamics Network Operation Center (NOC) as well as a number of other components that can be installed by the enterprise. The current status can be obtained synchronously. It is also possible to receive notifications whenever the status changes.

To obtain the current status, call the GDConnectivityManager.getActiveNetworkInfo method.

To receive notifications, register a receiver class:

See also
GDStateAction for details of authorization and update events, which are also sent by local broadcast.

Code Snippets

The following code snippets illustrate some common tasks.

Register for notification

public class MainActivity extends Activity {
// Override annotation should go here
public void onResume() {
super.onResume();
GDAndroid.getInstance().registerReceiver(new BroadcastReceiver() {
// Override annotation should go here
public void onReceive(Context context, Intent intent) {
//
// GDNetworkInfo gdNetworkInfo = GDConnectivityManager.getActiveNetworkInfo();
//
}
}, new IntentFilter(GDNetworkStatus.GD_CONNECTIVITY_ACTION));
}
}

The above snippet shows:

  • Instantiation of an anonymous inner class object as the receiver.
  • Instantiation of new Intent Filter as the filter.

The above snippet shows:

  • Registration for notification of changes in connection status. The observer code is specified by a selector.
  • Implementation of the selector, which displays a message to the user.

Public Member Functions

boolean isConnected ()
 Basic connection status. More...
 
boolean isAvailable ()
 Connection availability. More...
 
boolean isPushChannelAvailable ()
 Push Channel availability. More...
 
boolean isBlocked ()
 Network block status. More...
 
boolean isCaptivePortal ()
 Is captive portal Detected. More...
 
boolean isUnknownOutage ()
 Is Unknown Outage. More...
 
String getTypeName ()
 Name of the type of network through which the application is connected. More...
 
int getType ()
 Numeric code for the type of network through which the application is connected. More...
 

Member Function Documentation

◆ isConnected()

boolean isConnected ( )

This method returns a similar value to android.net.NetworkInfo.isConnected() but for the connection to the BlackBerry Dynamics infrastructure.

Returns
true if the application is connected to the BlackBerry Dynamics infrastructure.
false otherwise.

◆ isAvailable()

boolean isAvailable ( )

This method returns a similar value to android.net.NetworkInfo.isAvailable() but for the connection to the BlackBerry Dynamics infrastructure.

Returns
true if connection to the BlackBerry Dynamics infrastructure is available.
false otherwise.

◆ isPushChannelAvailable()

boolean isPushChannelAvailable ( )

Call this method to check that the BlackBerry Dynamics Push Channel service is available. For an overall description of how to use the service, see under PushChannel .

A change to the availability of the Push Channel service will trigger an infrastructure status change notification to the application. See the class description, above, for details of how to register for these notifications.

Returns
true if the Push Channel service is available.
false otherwise.

◆ isBlocked()

boolean isBlocked ( )

Call this method to check whether connection to the BlackBerry Dynamics infrastructure is blocked by a current device setting. The following settings are in scope of this method.

  • Android Data Saver. This setting can be modified by the end user, at run time.
Returns
true if connection to the infrastructure is blocked by a current device setting.
false otherwise.
See also
https://developer.android.com/training/basics/network-ops/data-saver.html for information about Android Data Saver.

◆ isCaptivePortal()

boolean isCaptivePortal ( )

Call this method to check that a captive portal has been detected with the current Wi-Fi connection.

This attribute will be updated once the DataConnectivityCheckTask completes.

Returns
true if a captive portal was detected.
false otherwise.

◆ isUnknownOutage()

boolean isUnknownOutage ( )

Call this method to check if an unknown outage has been detected with the current Wi-Fi connection.

This attribute will be updated once the DataConnectivityCheckTask completes.

Returns
true if an unknown outage was detected.
false otherwise.

◆ getTypeName()

String getTypeName ( )

This method returns a similar value to android.net.NetworkInfo.getTypeName() but for the connection to the BlackBerry Dynamics infrastructure.

Returns
String containing the name of the connected network type, for example "MOBILE" or "WIFI", or null if there is no connection.

◆ getType()

int getType ( )

This method returns a similar value to android.net.NetworkInfo.getType() but for the connection to the BlackBerry Dynamics infrastructure.

The TYPE_ values defined by the native android.net.ConnectivityManager class are used, for example:

  • ConnectivityManager.TYPE_MOBILE for a mobile data (cellular) network.
  • ConnectivityManager.TYPE_WIFI for a Wi-Fi network.
Returns
int representing the connected network type.