Android Lollipop defaults to Mobile Data when Wi-Fi has not Internet access?

前端 未结 4 619
时光说笑
时光说笑 2020-12-14 18:56

Android Lollipop seems to default to Mobile Data when the Wi-Fi you are connected to has no Internet access. Does anybody know if this is officiall

4条回答
  •  再見小時候
    2020-12-14 19:34

    By default, Android 5.0 will only send network requests over networks that it detect have an active internet connection so while it may be 'connected' to the wifi, it is not going to send any data over the network.

    However, the Android 5.0 APIs guide talks about the new multiple network support:

    Android 5.0 provides new multi-networking APIs that let your app dynamically scan for available networks with specific capabilities, and establish a connection to them. This functionality is useful when your app requires a specialized network, such as an SUPL, MMS, or carrier-billing network, or if you want to send data using a particular type of transport protocol.

    This allows you to build a NetworkRequest for a TRANSPORT_WIFI type and direct traffic to it via Network.openConnection() when you receive a onAvailable() callback if you must have certain connections happen over wifi even when the wifi network does not have internet access.

提交回复
热议问题