android网络状态检查

阅读更多

 

ConnectivityManager manager = (ConnectivityManager)getSystemService(
                Context.CONNECTIVITY_SERVICE);
        State mobile = manager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState();
        State wifi = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState();
       //移动网络
	if(mobile == State.CONNECTED||mobile==State.CONNECTING)
        return;
	//wifi网络
        if(wifi == State.CONNECTED||wifi==State.CONNECTING)
        return;

 

你可能感兴趣的:(android,网络,检查)