当前位置: 首页>>代码示例>>Java>>正文


Java Network.equals方法代码示例

本文整理汇总了Java中android.net.Network.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Network.equals方法的具体用法?Java Network.equals怎么用?Java Network.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.net.Network的用法示例。


在下文中一共展示了Network.equals方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAllNetworksFiltered

import android.net.Network; //导入方法依赖的package包/类
/**
 * Returns all connected networks that are useful and accessible to Chrome.
 * Only callable on Lollipop and newer releases.
 * @param ignoreNetwork ignore this network as if it is not connected.
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static Network[] getAllNetworksFiltered(
        ConnectivityManagerDelegate connectivityManagerDelegate, Network ignoreNetwork) {
    Network[] networks = connectivityManagerDelegate.getAllNetworksUnfiltered();
    // Whittle down |networks| into just the list of networks useful to us.
    int filteredIndex = 0;
    for (Network network : networks) {
        if (network.equals(ignoreNetwork)) {
            continue;
        }
        final NetworkCapabilities capabilities =
                connectivityManagerDelegate.getNetworkCapabilities(network);
        if (capabilities == null || !capabilities.hasCapability(NET_CAPABILITY_INTERNET)) {
            continue;
        }
        if (capabilities.hasTransport(TRANSPORT_VPN)) {
            // If we can access the VPN then...
            if (connectivityManagerDelegate.vpnAccessible(network)) {
                // ...we cannot access any other network, so return just the VPN.
                return new Network[] {network};
            } else {
                // ...otherwise ignore it as we cannot use it.
                continue;
            }
        }
        networks[filteredIndex++] = network;
    }
    return Arrays.copyOf(networks, filteredIndex);
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:35,代码来源:NetworkChangeNotifierAutoDetect.java

示例2: getDnsServerAddresses

import android.net.Network; //导入方法依赖的package包/类
@Override
@TargetApi(21)
public String[] getDnsServerAddresses() {
    ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    Network[] networks = connectivityManager == null ? null : connectivityManager.getAllNetworks();
    if (networks == null) {
        return new String[0];
    }
    final Network activeNetwork = getActiveNetwork(connectivityManager);
    List<String> servers = new ArrayList<>();
    int vpnOffset = 0;
    for (Network network : networks) {
        LinkProperties linkProperties = connectivityManager.getLinkProperties(network);
        if (linkProperties == null) {
            continue;
        }
        NetworkInfo networkInfo = connectivityManager.getNetworkInfo(network);
        final boolean isActiveNetwork = network.equals(activeNetwork);
        if (networkInfo != null && isActiveNetwork && networkInfo.getType() == ConnectivityManager.TYPE_VPN) {
            final List<String> tmp = getIPv4First(linkProperties.getDnsServers());
            servers.addAll(0, tmp);
            vpnOffset += tmp.size();
        } else if (hasDefaultRoute(linkProperties) || isActiveNetwork) {
            servers.addAll(vpnOffset, getIPv4First(linkProperties.getDnsServers()));
        } else {
            servers.addAll(getIPv4First(linkProperties.getDnsServers()));
        }
    }
    return servers.toArray(new String[servers.size()]);
}
 
开发者ID:kriztan,项目名称:Pix-Art-Messenger,代码行数:31,代码来源:AndroidUsingLinkProperties.java

示例3: getDnsServerAddresses

import android.net.Network; //导入方法依赖的package包/类
@Override
@TargetApi(21)
public String[] getDnsServerAddresses() {
    ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    Network[] networks = connectivityManager == null ? null : connectivityManager.getAllNetworks();
    if (networks == null) {
        return new String[0];
    }
    final Network activeNetwork = getActiveNetwork(connectivityManager);
    List<String> servers = new ArrayList<>();
    int vpnOffset = 0;
    for(Network network : networks) {
        LinkProperties linkProperties = connectivityManager.getLinkProperties(network);
        if (linkProperties == null) {
            continue;
        }
        NetworkInfo networkInfo = connectivityManager.getNetworkInfo(network);
        final boolean isActiveNetwork = network.equals(activeNetwork);
        if (networkInfo != null && isActiveNetwork && networkInfo.getType() == ConnectivityManager.TYPE_VPN) {
            final List<String> tmp = getIPv4First(linkProperties.getDnsServers());
            servers.addAll(0, tmp);
            vpnOffset += tmp.size();
        } else if (hasDefaultRoute(linkProperties) || isActiveNetwork) {
            servers.addAll(vpnOffset, getIPv4First(linkProperties.getDnsServers()));
        } else {
            servers.addAll(getIPv4First(linkProperties.getDnsServers()));
        }
    }
    return servers.toArray(new String[servers.size()]);
}
 
开发者ID:siacs,项目名称:Conversations,代码行数:31,代码来源:AndroidUsingLinkProperties.java


注:本文中的android.net.Network.equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。