Updated to use the ACCESS_NETWORK_STATE permission