FireflyApi network
3.5 Network
The network feature needs to add the following permissions:
-
Get the MAC address of the device's Ethernet
Function:public String getEthMacAddress()Description:Get the MAC address of the device's EthernetReturn:Returns null if failedExample: -
Get the IP address of the device's Ethernet
Function:public String getEthIpAddress()Description:Get the IP address of the device's EthernetExample: -
Get device's Ethernet information
Function:public EthernetInfo getEthInfo()Description:Get device's Ethernet information (including: ip, netmask, gateway, dns1, dns2)Example: -
Set the IP address of the device's Ethernet
Function:public boolean setEthIPAddress(boolean use_static_ip,String mIpaddr, String mMask, String mGw, String mDns1,String mDns2)Description:Set the IP address of the device's EthernetParameters:use_static_ip. When true is set to static ip, other parameters are valid, otherwise, when false is set to dynamic ip, it will automatically obtain ip addressReturn:Returns false if failedExample: -
Whether Ethernet is currently connected
Function:public boolean isEthConnect()Description:Whether Ethernet is currently connectedExample: -
Set Ethernet on/off
Function:public boolean setEthernetEnabled(boolean enabled)Description:Set Ethernet on/offParameters:enabled true(open)/false(close)Example: -
Get the type of current network connection
Function:public String getCurNetworkType()Description:Get the type of current network connectionReturn:UNKNOWN/WIFI/ETHERNET/MOBILERemark:Use BroadcatReceiver to monitor the Ethernet ConnectState changes through the monitoring of ETHERNET_STATE_CHANGED_ACTION = "android.net.ethernet.ETHERNET_STATE_CHANGED".int connectState=intent.getIntExtra("ethernet_state", -1)Example: