Android TelephonyManager.getNetworkType() returned constant values in bearer speed order?

Posted by Rob Shepherd on Stack Overflow See other posts from Stack Overflow or by Rob Shepherd
Published on 2010-03-08T19:47:07Z Indexed on 2010/03/08 19:51 UTC
Read the original article Hit count: 527

Filed under:

TelephonyManager.getNetworkType() returns one of the constant values.

It appears that the constant values have an integer order, by possible bearer link speed.

I know using constant values used in the following manner is generally bad,

however could one use this to determine a basic cutoff for application functionality and have it work between API levels? (in API-v1 there was nothing above 0x03)

if( telephonyManager.getNetworkType() > TelephonyManager.NETWORK_TYPE_EDGE )
{
     return "3G! party on!";
}
else if( telephonyManager.getNetworkType() > TelephonyManager.NETWORK_TYPE_UNKNOWN )
{
     return "2G, OK. just don't go nuts!";
}
else 
{
     return "No data sorry"
}

© Stack Overflow or respective owner

Related posts about android