Adobe Air - 检测连接是 WIFI、3G 还是 EDGE [英] Adobe Air - Detect if connection is WIFI, 3G, or EDGE
本文介绍了Adobe Air - 检测连接是 WIFI、3G 还是 EDGE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要确定设备使用的连接类型.在 iOS 上区分 WIFI 和 3G 似乎不是问题(使用 NetworkInfo ANE) 和 Android(使用本机 NetworkInfo 类),但我不知道如何进一步区分快速(3G、4G)和慢速(EDGE)连接.有没有办法用 Adobe Air 做到这一点?
I need to determine which connection type a device is using. Distinguishing between WIFI and 3G doesn't seem to be a problem on iOS (using the NetworkInfo ANE) and Android (using the native NetworkInfo class) but I've got no clue how to further distinguish between a fast (3G, 4G) and slow (EDGE) connection. Is there a way to do this with Adobe Air?
推荐答案
试试这个来检测 iOS 上的移动与 Wifi.这需要 Adobe 原生扩展NetworkInfo"
import com.adobe.nativeExtensions.Networkinfo.InterfaceAddress;
import com.adobe.nativeExtensions.Networkinfo.NetworkInfo;
import com.adobe.nativeExtensions.Networkinfo.NetworkInterface;
var vNetworkInterfaces:Object;
if (flash.net.NetworkInfo.isSupported)
{
vNetworkInterfaces = getDefinitionByName('flash.net.NetworkInfo')['networkInfo']['findInterfaces']();
mytrace("fall 1" );
}
else
{
vNetworkInterfaces = getDefinitionByName('com.adobe.nativeExtensions.Networkinfo.NetworkInfo')['networkInfo']['findInterfaces']();
mytrace("fall 2" );
}
var hasWifi: Boolean = false;
var hasMobile: Boolean = false;
for each (var networkInterface:Object in vNetworkInterfaces)
{
if ( networkInterface.active && (networkInterface.name == "en0" || networkInterface.name == "en1") ) hasWifi = true;
if ( networkInterface.active && (networkInterface.name == "pdp_ip0" || networkInterface.name == "pdp_ip1" || networkInterface.name == "pdp_ip2") ) hasMobile = true;
mytrace( "active: " + networkInterface.active );
mytrace( "displayName: " + networkInterface.displayName );
mytrace( "name: " + networkInterface.name );
mytrace( "hwAddress: " + networkInterface.hardwareAddress );
mytrace( "--------------------" );
}
mytrace( "has Mobile Internet: " + hasMobile );
mytrace( "has Wifi Internet: " + hasWifi );
这篇关于Adobe Air - 检测连接是 WIFI、3G 还是 EDGE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文