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 a
Solution 1:
Sure would you not just use this: getNetworkType()
booleanhasNetwork= 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
Solution 2:
The above answer did not work for one of my app users - he was connected to the Network but his NetworkType was unknown. Screenshot: http://dl.dropbox.com/u/5072192/SC20130317-161413.png
I am instead checking for the NetworkOperator field. (From the first answer here What is the correct way of checking for mobile network available (no data connection))
publicstaticbooleanisMobileAvailable(Context acontext) {
TelephonyManagertel= (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
return (tel.getNetworkOperator() != null && !tel.getNetworkOperator().equals(""));
}
Post a Comment for "How To Check For Phone Network On Android Devices"