我需要确定设备正在使用哪种连接类型。
在iOS(使用NetworkInfo ANE)和Android(使用 native NetworkInfo类)上,区分WIFI和3G似乎不是问题,但是我不知道如何进一步区分快速(3G,4G)和慢速(EDGE)连接。
有没有办法用Adobe Air做到这一点?

最佳答案

尝试此操作以检测iOS上的移动设备与Wifi。这需要Adobe native 扩展“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 );

关于actionscript-3 - Adobe Air-检测连接是WIFI,3G还是EDGE,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9872348/

10-12 12:43