final NetworkInfo netInfo = connectivityManager.getNetworkInfo(network);
NetworkCapabilities actNw = connectivityManager.getNetworkCapabilities(nw);
if(actNw != null && (actNw.hasTransport(NetworkCapabilities.TRANSPORT_WIFI))){
Timber.d("NetWorkDetails_%s",netInfo);
}
上面的代码我在一个循环中运行,allnetworks将日志显示为
NetWorkDetails_Wifi[type: MOBILE[LTE], state: CONNECTED/CONNECTED, reason: (unspecified), extra: ims, failover: false, available: true, roaming: false]
NetWorkDetails_Wifi[type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: (none), failover: false, available: true, roaming: false]
为什么它包括移动[lte],即使我检查的传输类型为wifi?
暂无答案!
目前还没有任何答案,快来回答吧!