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


Java NetworkInfo.DetailedState方法代码示例

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


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

示例1: newInstance

import android.net.NetworkInfo; //导入方法依赖的package包/类
public static NetworkInfo newInstance(
        NetworkInfo.DetailedState detailedState, int type, int subType, boolean isAvailable, boolean isConnected,
        boolean isRoaming) {
    NetworkInfo networkInfo = org.robolectric.shadows.ShadowNetworkInfo.newInstance(
            detailedState, type, subType, isAvailable, isConnected);
    ShadowNetworkInfo info = (ShadowNetworkInfo) shadowOf(networkInfo);
    info.setRoaming(isRoaming);
    return networkInfo;
}
 
开发者ID:Doist,项目名称:JobSchedulerCompat,代码行数:10,代码来源:ShadowNetworkInfo.java

示例2: setNetworkInfo

import android.net.NetworkInfo; //导入方法依赖的package包/类
public static void setNetworkInfo(Context context, boolean isConnected, boolean isRoaming, boolean isWifi) {
    ShadowConnectivityManager manager =
            shadowOf((ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE));
    NetworkInfo.DetailedState detailedState =
            isConnected ? NetworkInfo.DetailedState.CONNECTED : NetworkInfo.DetailedState.DISCONNECTED;
    int type = isConnected ? (isWifi ? ConnectivityManager.TYPE_WIFI : ConnectivityManager.TYPE_MOBILE) : -1;
    NetworkInfo networkInfo =
            ShadowNetworkInfo.newInstance(detailedState, type, 0, isConnected, isConnected, isRoaming);
    manager.setActiveNetworkInfo(networkInfo);
}
 
开发者ID:Doist,项目名称:JobSchedulerCompat,代码行数:11,代码来源:DeviceTestUtils.java

示例3: getWifiName

import android.net.NetworkInfo; //导入方法依赖的package包/类
public String getWifiName(Context context) {
    WifiManager manager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
    if (manager.isWifiEnabled()) {
        WifiInfo wifiInfo = manager.getConnectionInfo();
        if (wifiInfo != null) {
            NetworkInfo.DetailedState state = WifiInfo.getDetailedStateOf(wifiInfo.getSupplicantState());
            if (state == NetworkInfo.DetailedState.CONNECTED || state == NetworkInfo.DetailedState.OBTAINING_IPADDR) {
                return wifiInfo.getSSID();
            }
        }
    }
    return null;
}
 
开发者ID:BloomBooks,项目名称:BloomReader,代码行数:14,代码来源:GetFromWiFiActivity.java

示例4: getDetailedState

import android.net.NetworkInfo; //导入方法依赖的package包/类
public NetworkInfo.DetailedState getDetailedState() {
    return detailedState;
}
 
开发者ID:datalink747,项目名称:Rx_java2_soussidev,代码行数:4,代码来源:Connectivity.java

示例5: getDetailedState

import android.net.NetworkInfo; //导入方法依赖的package包/类
/** @see NetworkInfo#getDetailedState() */
public NetworkInfo.DetailedState getDetailedState() {
  return detailedState;
}
 
开发者ID:greyfoxit,项目名称:RxNetwork,代码行数:5,代码来源:RxNetworkInfo.java


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