Android 9 有线网络的方法适配

前言

最近在适配android 9 的网络模块,总体来说还是有一些变动的,下面为大家列出部分网络的变动方法。

有线网络:

EthernetManager 类

新增 isAvailable 方法判断是否连接上有线网络,只能通过反射使用此方法

public boolean isAvailable() {
        return getAvailableInterfaces().length > 0;
    }

setConfiguration 方法 新增2个参数

    /**
     * Set Ethernet configuration.
     */
    public void setConfiguration(String iface, IpConfiguration config) {
        try {
            mService.setConfiguration(iface, config);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
getConfiguration方法 新增1个参数
   /**
     * Get Ethernet configuration.
     * @return the Ethernet Configuration, contained in {@link IpConfiguration}.
     */
    public IpConfiguration getConfiguration(String iface) {
        try {
            return mService.getConfiguration(iface);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

以上方法主要是用于 手动IP 自动IP 的切换,手动IP的设置,有线网络的判断。

你可能感兴趣的:(android,android,TV,开发)