문제

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.

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top