Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.fourthline.cling.android
Class AndroidRouter

    java.lang.Object
      org.fourthline.cling.transport.RouterImpl
          org.fourthline.cling.android.AndroidRouter

All Implemented Interfaces:
  Router

    public class AndroidRouter

extends RouterImpl

Monitors all network connectivity changes, switching the router accordingly.

Author:
  Michael Pujos, Christian Bauer

Field Summary
`protected android.content.BroadcastReceiver` | `broadcastReceiver`
`protected android.net.wifi.WifiManager.MulticastLock` | `multicastLock`
`protected android.net.NetworkInfo` | `networkInfo`
`protected android.net.wifi.WifiManager.WifiLock` | `wifiLock`

Fields inherited from class org.fourthline.cling.transport.RouterImpl
`configuration, datagramIOs, enabled, multicastReceivers, networkAddressFactory, protocolFactory, readLock, routerLock, streamClient, streamServers, writeLock`

Constructor Summary
`AndroidRouter(UpnpServiceConfiguration configuration, ProtocolFactory protocolFactory, android.content.Context context)`

Method Summary
`protected android.net.wifi.WifiManager.WifiLock` | `createWiFiLock()`
`boolean` | `disable()` Unbinds all sockets and stops all listening threads for datagrams and streams.
`boolean` | `enable()` Initializes listening services: First an instance of `MulticastReceiver` is bound to each network interface.
`boolean` | `enableWiFi()`
`protected int` | `getLockTimeoutMillis()`
`android.net.NetworkInfo` | `getNetworkInfo()`
`protected void` | `handleRouterExceptionOnNetworkTypeChange(RouterException ex)`
`boolean` | `isEthernet()`
`boolean` | `isMobile()`
`boolean` | `isWifi()`
`protected void` | `onNetworkTypeChange(android.net.NetworkInfo oldNetwork, android.net.NetworkInfo newNetwork)` Can be overriden by subclasses to do additional work.
`protected void` | `setWifiLock(boolean enable)`
`protected void` | `setWiFiMulticastLock(boolean enable)`
`void` | `shutdown()` Disables the router and releases all other resources.
`void` | `unregisterBroadcastReceiver()`

Methods inherited from class org.fourthline.cling.transport.RouterImpl
`broadcast, disable, enable, getActiveStreamServers, getConfiguration, getProtocolFactory, handleStartFailure, isEnabled, lock, lock, received, received, send, send, startAddressBasedTransports, startInterfaceBasedTransports, unlock`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### multicastLock

    protected android.net.wifi.WifiManager.MulticastLock multicastLock

### wifiLock

    protected android.net.wifi.WifiManager.WifiLock wifiLock

### networkInfo

    protected android.net.NetworkInfo networkInfo

### broadcastReceiver

    protected android.content.BroadcastReceiver broadcastReceiver

Constructor Detail

### AndroidRouter

    public AndroidRouter(UpnpServiceConfiguration configuration,
                         ProtocolFactory protocolFactory,
                         android.content.Context context)
                  throws InitializationException

Throws:
  `InitializationException`

Method Detail

### getLockTimeoutMillis

    protected int getLockTimeoutMillis()

  Overrides:
    `getLockTimeoutMillis` in class `RouterImpl`
  Returns:
    Defaults to 6 seconds, should be longer than it takes the router to be enabled/disabled.

### shutdown

    public void shutdown()
                  throws RouterException

  Description copied from interface: `Router`
  Disables the router and releases all other resources.

  Specified by:
    `shutdown` in interface `Router`
  Overrides:
    `shutdown` in class `RouterImpl`
  Throws:
    `RouterException`

### enable

    public boolean enable()
                   throws RouterException

  Description copied from class: `RouterImpl`
  Initializes listening services: First an instance of `MulticastReceiver` is bound to each network interface. Then an instance of `DatagramIO` and `StreamServer` is bound to each bind address returned by the network address factory, respectively. There is only one instance of `StreamClient` created and managed by this router.

  Specified by:
    `enable` in interface `Router`
  Overrides:
    `enable` in class `RouterImpl`
  Returns:
    `true` if the router was enabled. `false` if it's already running.
  Throws:
    `RouterException`

### disable

    public boolean disable()
                    throws RouterException

  Description copied from interface: `Router`
  Unbinds all sockets and stops all listening threads for datagrams and streams.

  Specified by:
    `disable` in interface `Router`
  Overrides:
    `disable` in class `RouterImpl`
  Returns:
    `true` if the router was disabled. `false` if it wasn't running.
  Throws:
    `RouterException`

### getNetworkInfo

    public android.net.NetworkInfo getNetworkInfo()

### isMobile

    public boolean isMobile()

### isWifi

    public boolean isWifi()

### isEthernet

    public boolean isEthernet()

### enableWiFi

    public boolean enableWiFi()

### unregisterBroadcastReceiver

    public void unregisterBroadcastReceiver()

### setWiFiMulticastLock

    protected void setWiFiMulticastLock(boolean enable)

### setWifiLock

    protected void setWifiLock(boolean enable)

### createWiFiLock

    protected android.net.wifi.WifiManager.WifiLock createWiFiLock()

### onNetworkTypeChange

    protected void onNetworkTypeChange(android.net.NetworkInfo oldNetwork,
                                       android.net.NetworkInfo newNetwork)
                                throws RouterException

  Can be overriden by subclasses to do additional work.

  Parameters:
    `oldNetwork` - `null` when first called by constructor.
  Throws:
    `RouterException`

### handleRouterExceptionOnNetworkTypeChange

    protected void handleRouterExceptionOnNetworkTypeChange(RouterException ex)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2013 4th Line GmbH, Switzerland. All Rights Reserved.