public class EthernetManager
extends java.lang.Object
Note that only one interface is supported.
Unless noted, all API methods require the
android.permission.ACCESS_NETWORK_STATE and/or
android.permission.CHANGE_NETWORK_STATE
permissions, depending on whether you are accessing or changing the Ethernet
configuration. If your application does not have these permissions it will
not have access to any Ethernet service feature.
| Constructor and Description |
|---|
EthernetManager(android.content.Context context)
Class constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
configureInterface(EthernetConfiguration info)
Configures the interface with the given configuration.
|
EthernetConnectionMode |
getConnectionMode()
Returns the configured connection mode of the interface.
|
java.net.InetAddress |
getDns1()
Returns the configured DNS1 address of the interface.
|
java.net.InetAddress |
getDns2()
Returns the configured DNS2 address of the interface.
|
java.net.InetAddress |
getGateway()
Returns the configured gateway address of the interface.
|
java.lang.String |
getInterfaceName()
Returns the Ethernet interface name.
|
java.net.InetAddress |
getIp()
Returns the configured IP address of the interface.
|
java.lang.String |
getMacAddress()
Reads the MAC address of the Ethernet interface.
|
java.net.InetAddress |
getNetmask()
Returns the configured netmask of the interface.
|
boolean |
isConnected()
Returns whether the Ethernet interface is connected or not.
|
boolean |
isEnabled()
Returns whether the interface is enabled or not.
|
void |
resetInterface()
Resets the Ethernet interface.
|
void |
setEnabled(boolean enable)
Enables or disables the interface.
|
public EthernetManager(android.content.Context context)
EthernetManager.context - Application context.java.lang.NullPointerException - If context == null.public java.lang.String getInterfaceName()
null if there is not any
interface.public boolean isEnabled()
true if the interface is enabled, false
otherwise.setEnabled(boolean)public void setEnabled(boolean enable)
enable - true to enable, false to disable.isEnabled()public boolean isConnected()
true if connected, false otherwise.public void resetInterface()
public EthernetConnectionMode getConnectionMode()
configureInterface(EthernetConfiguration),
EthernetConnectionModepublic java.net.InetAddress getIp()
null if could not be read.configureInterface(EthernetConfiguration)public java.net.InetAddress getDns1()
null if could not be read.configureInterface(EthernetConfiguration)public java.net.InetAddress getDns2()
null if could not be read.configureInterface(EthernetConfiguration)public java.net.InetAddress getGateway()
null if could not be
read.configureInterface(EthernetConfiguration)public java.net.InetAddress getNetmask()
null if could not be read.configureInterface(EthernetConfiguration)public java.lang.String getMacAddress()
null if could not be read.java.lang.NullPointerException - If the configured interface is null.public void configureInterface(EthernetConfiguration info) throws java.net.UnknownHostException
This method resets the interface to apply the new configuration.
info - Interface configuration.java.lang.IllegalArgumentException - If the interface name is invalid or
the connection mode is unknown.java.lang.NullPointerException - If info == null or
in a static configuration the IP, netmask,
gateway or DNS 1 addresses are null.java.net.UnknownHostException - If the given IP addresses cannot be
resolved.getConnectionMode(),
getDns1(),
getDns2(),
getGateway(),
getIp(),
getNetmask(),
EthernetConfiguration