Search code examples
androidnetwork-programmingtelephonymanager

How to check for phone network on Android devices


I know how to check if I have internet access (using the code from this post),but is it possible to check if a phone has telephone network access? For example someone might have access to the internet via Wifi but not have phone network access to send SMS or make calls.

In my case, while using a real device (Samsung Galaxy S), I am able to turn of my 3G network (then the phone will detect I am not connected to the internet), but I am still able to make phone calls and send SMS. I guess I must be using some other network...

How do I test whether the phone network is connected? Do I need the TelephonyManager?

Thankyou for your time.

Mel


Solution

  • Sure would you not just use this: getNetworkType()

    boolean hasNetwork = android.telephony.TelephonyManager.getNetworkType() != android.telephony.TelephonyManager.NETWORK_TYPE_UNKNOWN; 
    // True if the phone is connected to some type of network i.e. has signal