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?
Try this for detecting Mobile vs. Wifi on iOS. This requires the Adobe native extension "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 );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With