ConnectivityManager
conMan = (ConnectivityManager)
getSystemService(Context.CONNECTIVITY_SERVICE);
//mobile
State
mobile = conMan.getNetworkInfo(0).getState();
//wifi
State
wifi = conMan.getNetworkInfo(1).getState();
if (mobile ==
NetworkInfo.State.CONNECTED
||
mobile == NetworkInfo.State.CONNECTING) {
//mobile
}
else if (wifi ==
NetworkInfo.State.CONNECTED
||
wifi == NetworkInfo.State.CONNECTING) {
//wifi
}
No comments:
Post a Comment