Frage

Is there any method in telephony manager which can be used to see if the phone has any network?By that i mean i want to check if the phone has a telephone network, not if its has a data network. For example, if the user puts his phone on airplane mode, that means he doesn't have phone network to receive calls, send SMS etc. That's exactly the kind of thing i want to detect. Is there any method to do so?

thanks.

War es hilfreich?

Lösung

public static boolean checkMobileNetworkAvailable(Context context){
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    int networkType = tm.getNetworkType();
    return (networkType != TelephonyManager.NETWORK_TYPE_UNKNOWN);
}

from this so Thread. check if it helps you

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top