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


Java LinkAddress类代码示例

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


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

示例1: findVpnNetwork

import android.net.LinkAddress; //导入依赖的package包/类
private Network findVpnNetwork() {
    ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    Network[] networks = cm.getAllNetworks();
    for (Network network : networks) {
        LinkProperties linkProperties = cm.getLinkProperties(network);
        List<LinkAddress> addresses = linkProperties.getLinkAddresses();
        for (LinkAddress addr : addresses) {
            if (addr.getAddress().equals(VPN_ADDRESS)) {
                return network;
            }
        }
    }
    return null;
}
 
开发者ID:Genymobile,项目名称:gnirehtet,代码行数:15,代码来源:GnirehtetService.java

示例2: after

import android.net.LinkAddress; //导入依赖的package包/类
@Override
protected void after(XParam param) throws Throwable {
	switch (mMethod) {
	case getAddresses:
	case getAllAddresses:
		if (param.getResult() != null)
			if (isRestricted(param))
				param.setResult(new ArrayList<InetAddress>());
		break;

	case getAllLinkAddresses:
	case getLinkAddresses:
		if (param.getResult() != null)
			if (isRestricted(param))
				param.setResult(new ArrayList<LinkAddress>());
		break;

	case getStackedLinks:
		if (param.getResult() != null)
			if (isRestricted(param))
				param.setResult(new ArrayList<LinkProperties>());
		break;
	}
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:25,代码来源:XLinkProperties.java

示例3: getActiveInterface

import android.net.LinkAddress; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.M)
private String getActiveInterface() {
    final Network network = cm.getActiveNetwork();

    if (network == null) {
        return null;
    }

    final LinkProperties linkInfo = cm.getLinkProperties(network);

    if (linkInfo == null) {
        return null;
    }

    final List<LinkAddress> linkAddress = linkInfo.getLinkAddresses();

    if (linkAddress.isEmpty()) {
        return null;
    }

    final InetAddress address = linkAddress.get(0).getAddress();

    return address.getHostAddress();
}
 
开发者ID:chdir,项目名称:aria2-android,代码行数:25,代码来源:ConfigBuilder.java

示例4: getIp

import android.net.LinkAddress; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private String getIp(LinkProperties lp) {
    List<LinkAddress> las = lp.getLinkAddresses();
    for(LinkAddress la: las) {
        InetAddress inetAddress = la.getAddress();
        if (inetAddress instanceof Inet4Address) {
            //Log.d(TAG, lp.getInterfaceName() + ": " + inetAddress.getHostAddress());
            return inetAddress.getHostAddress();
        }
    }
    return null;
}
 
开发者ID:archos-sa,项目名称:aos-FileCoreLibrary,代码行数:13,代码来源:SambaDiscovery.java

示例5: getIPAddresses

import android.net.LinkAddress; //导入依赖的package包/类
@SuppressLint("NewApi")
IPAddress[] getIPAddresses(LinkProperties linkProperties) {
  IPAddress[] ipAddresses = new IPAddress[linkProperties.getLinkAddresses().size()];
  int i = 0;
  for (LinkAddress linkAddress : linkProperties.getLinkAddresses()) {
    ipAddresses[i] = new IPAddress(linkAddress.getAddress().getAddress());
    ++i;
  }
  return ipAddresses;
}
 
开发者ID:Piasy,项目名称:AppRTC-Android,代码行数:11,代码来源:NetworkMonitorAutoDetect.java

示例6: showIpConfigFields

import android.net.LinkAddress; //导入依赖的package包/类
@SuppressLint("NewApi")
private void showIpConfigFields() {
    WifiConfiguration config = null;

    mView.findViewById(R.id.ip_fields).setVisibility(View.VISIBLE);

    if (mAccessPoint != null && mAccessPoint.networkId != INVALID_NETWORK_ID) {
        config = mAccessPoint.getConfig();
    }

    if (mIpSettingsSpinner.getSelectedItemPosition() == STATIC_IP) {
        mView.findViewById(R.id.staticip).setVisibility(View.VISIBLE);
        if (mIpAddressView == null) {
            mIpAddressView = (TextView) mView.findViewById(R.id.ipaddress);
            mIpAddressView.addTextChangedListener(this);
            mGatewayView = (TextView) mView.findViewById(R.id.gateway);
            mGatewayView.addTextChangedListener(this);
            mNetworkPrefixLengthView = (TextView) mView.findViewById(
                    R.id.network_prefix_length);
            mNetworkPrefixLengthView.addTextChangedListener(this);
            mDns1View = (TextView) mView.findViewById(R.id.dns1);
            mDns1View.addTextChangedListener(this);
            mDns2View = (TextView) mView.findViewById(R.id.dns2);
            mDns2View.addTextChangedListener(this);
        }
        if (config != null) {
            LinkProperties linkProperties = config.linkProperties;
            Iterator<LinkAddress> iterator = linkProperties.getLinkAddresses().iterator();
            if (iterator.hasNext()) {
                LinkAddress linkAddress = iterator.next();
                mIpAddressView.setText(linkAddress.getAddress().getHostAddress());
                mNetworkPrefixLengthView.setText(Integer.toString(linkAddress
                        .getNetworkPrefixLength()));
            }

            for (RouteInfo route : linkProperties.getRoutes()) {
                if (route.isDefaultRoute()) {
                    mGatewayView.setText(route.getGateway().getHostAddress());
                    break;
                }
            }

            Iterator<InetAddress> dnsIterator = linkProperties.getDnses().iterator();
            if (dnsIterator.hasNext()) {
                mDns1View.setText(dnsIterator.next().getHostAddress());
            }
            if (dnsIterator.hasNext()) {
                mDns2View.setText(dnsIterator.next().getHostAddress());
            }
        }
    } else {
        mView.findViewById(R.id.staticip).setVisibility(View.GONE);
    }
}
 
开发者ID:voyagewu,项目名称:AndroidSettingDemoAP,代码行数:55,代码来源:WifiConfigController.java


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