1. 현재 Internet 연결이 3g인지 wifi인지 확인하는 함수.
public static boolean is3GNetwork(Context mContext) {
ConnectivityManager cm = (ConnectivityManager)mContext
.getSystemService(Context.CONNECTIVITY_SERVICE);
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
if (netInfo.getType() == ConnectivityManager.TYPE_MOBILE) {
return true;
}
return false;
}
2. 현재 Network에 연결되어 있는지 아닌지를 확인하는 함수.
public static boolean isOnline(Context mContext) {
ConnectivityManager cm = (ConnectivityManager)mContext
.getSystemService(Context.CONNECTIVITY_SERVICE);
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
if (netInfo != null && netInfo.isConnectedOrConnecting()) {
return true;
}
return false;
}
답글 남기기
로그인을 해야 댓글을 남길 수 있습니다.