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


Java ConnectivityManager.TYPE_VPN属性代码示例

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


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

示例1: testNetworkChangeNotifierIsOnline

@UiThreadTest
@MediumTest
@Feature({"Android-AppBase"})
public void testNetworkChangeNotifierIsOnline() throws InterruptedException {
    Intent intent = new Intent(ConnectivityManager.CONNECTIVITY_ACTION);
    // For any connection type it should return true.
    for (int i = ConnectivityManager.TYPE_MOBILE; i < ConnectivityManager.TYPE_VPN; i++) {
        mConnectivityDelegate.setActiveNetworkExists(true);
        mConnectivityDelegate.setNetworkType(i);
        mReceiver.onReceive(getInstrumentation().getTargetContext(), intent);
        assertTrue(NetworkChangeNotifier.isOnline());
    }
    mConnectivityDelegate.setActiveNetworkExists(false);
    mReceiver.onReceive(getInstrumentation().getTargetContext(), intent);
    assertFalse(NetworkChangeNotifier.isOnline());
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:16,代码来源:NetworkChangeNotifierTest.java

示例2: connectionTypeString

private String connectionTypeString(int connectionType) {
    switch (connectionType) {
        case ConnectivityManager.TYPE_WIFI:
            return "Wifi";
        case ConnectivityManager.TYPE_BLUETOOTH:
            return "Bluetooth";
        case ConnectivityManager.TYPE_ETHERNET:
            return "Ethernet";
        case ConnectivityManager.TYPE_MOBILE:
            return "Mobile";
        case ConnectivityManager.TYPE_MOBILE_DUN:
            return "Mobile dun";
        case ConnectivityManager.TYPE_VPN:
            return "VPN";
        default:
            return "Unknown";
    }
}
 
开发者ID:wkmeijer,项目名称:CS4160-trustchain-android,代码行数:18,代码来源:PeerListAdapter.java

示例3: isMobileConnected

public static boolean isMobileConnected() {
    checkInitialization();
    ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
    if (cm != null) {
        NetworkInfo info = cm.getActiveNetworkInfo();
        return info != null && info.isConnected() &&
                (info.getType() == ConnectivityManager.TYPE_MOBILE ||
                        info.getType() == ConnectivityManager.TYPE_MOBILE_DUN ||
                        info.getType() == ConnectivityManager.TYPE_VPN);
    }
    return false;
}
 
开发者ID:xinpianchang,项目名称:NSMPlayer-Android,代码行数:12,代码来源:ConnectionUtils.java

示例4: networkToInfo

@SuppressLint("NewApi")
private NetworkInformation networkToInfo(Network network) {
  LinkProperties linkProperties = connectivityManager.getLinkProperties(network);
  // getLinkProperties will return null if the network is unknown.
  if (linkProperties == null) {
    Logging.w(TAG, "Detected unknown network: " + network.toString());
    return null;
  }
  if (linkProperties.getInterfaceName() == null) {
    Logging.w(TAG, "Null interface name for network " + network.toString());
    return null;
  }

  NetworkState networkState = getNetworkState(network);
  if (networkState.connected && networkState.getNetworkType() == ConnectivityManager.TYPE_VPN) {
    // If a VPN network is in place, we can find the underlying network type via querying the
    // active network info thanks to
    // https://android.googlesource.com/platform/frameworks/base/+/d6a7980d
    networkState = getNetworkState();
  }
  ConnectionType connectionType = getConnectionType(networkState);
  if (connectionType == ConnectionType.CONNECTION_NONE) {
    // This may not be an error. The OS may signal a network event with connection type
    // NONE when the network disconnects.
    Logging.d(TAG, "Network " + network.toString() + " is disconnected");
    return null;
  }

  // Some android device may return a CONNECTION_UNKNOWN_CELLULAR or CONNECTION_UNKNOWN type,
  // which appears to be usable. Just log them here.
  if (connectionType == ConnectionType.CONNECTION_UNKNOWN
      || connectionType == ConnectionType.CONNECTION_UNKNOWN_CELLULAR) {
    Logging.d(TAG, "Network " + network.toString() + " connection type is " + connectionType
            + " because it has type " + networkState.getNetworkType() + " and subtype "
            + networkState.getNetworkSubType());
  }

  NetworkInformation networkInformation =
      new NetworkInformation(linkProperties.getInterfaceName(), connectionType,
          networkToNetId(network), getIPAddresses(linkProperties));
  return networkInformation;
}
 
开发者ID:Piasy,项目名称:AppRTC-Android,代码行数:42,代码来源:NetworkMonitorAutoDetect.java


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