Testing for 4G Networks in Android

Testing for 4G Networks in Android

In order to test for the presence / absence of WiMax (4G) you need to do something like the following:


private boolean isNetworkAvailable() {
ConnectivityManager connec = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo mobileInfo = connec.getNetworkInfo(0);
NetworkInfo wifiInfo = connec.getNetworkInfo(1);
NetworkInfo wimaxInfo = connec.getNetworkInfo(6);

if (wimaxInfo!=null) {
return mobileInfo.isConnectedOrConnecting() || wifiInfo.isConnectedOrConnecting() || wimaxInfo.isConnectedOrConnecting();
}
else {
return mobileInfo.isConnectedOrConnecting() || wifiInfo.isConnectedOrConnecting();
}
}

A little hard won knowledge from the trenches.

2 thoughts on “Testing for 4G Networks in Android

  1. hey man.. I have it implemented the same as you, BUT late this week people started complaining that my app was working correctly on one of their TMOBILE sim and not working on another TMOBILE sim. IN THE SAME PHONE!!

    I am wondering if the new tmobile 4g has something with do with that!

    Thanks
    Rafa

    Like

    1. Thanks for the heads up. Not at all surprising.

      For all the love it seems to get, Android is one huge pain in the neck, support wise. Don’t even get me started on working with the Camera from phone to phone, even by the same manufacturer. I’m looking at you, Motorola Droid X and R2D2.

      The fact that there are issues with 4G implementation is par for the course, given my experience.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s