public final class

Network

extends Object
java.lang.Object
   ↳ com.neomades.io.Network

Class Overview

Class utility that describes the status of network.

To use this class, the NETWORK_STATE permission must be declared in the URS file.

Summary

Constants
int TYPE_ETHERNET Ethernet
int TYPE_MOBILE Cellular, GPRS, 3G, Roaming
int TYPE_NONE No network
int TYPE_WIFI WIFI
Public Methods
static int getActiveType()
Returns the active network type.
static boolean isConnected(int type)
Checks whether the network connectivity exists and could establish connections and pass data.
static boolean isConnected()
Checks whether the network connectivity exists and could establish connections and pass data.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int TYPE_ETHERNET

Ethernet

Constant Value: 4 (0x00000004)

public static final int TYPE_MOBILE

Cellular, GPRS, 3G, Roaming

Constant Value: 1 (0x00000001)

public static final int TYPE_NONE

No network

Constant Value: 0 (0x00000000)

public static final int TYPE_WIFI

WIFI

Constant Value: 2 (0x00000002)

Public Methods

public static int getActiveType ()

Returns the active network type.

Returns
  • the active network type
Throws
SecurityException if the type could be known for permissions reasons

public static boolean isConnected (int type)

Checks whether the network connectivity exists and could establish connections and pass data. The network type is given by parameter.

Parameters
type the type of network (WIFI, MOBILE, ETHERNET)
Returns
  • true if the network is connected
Throws
SecurityException if the state could be known for permissions reasons
RuntimeException The platform does not support this function.

public static boolean isConnected ()

Checks whether the network connectivity exists and could establish connections and pass data. (through the active network type).

Returns
  • true if the network is connected
Throws
SecurityException if the state could be known for permissions reasons