问题
I have a Nexus 5x running MarshMallow 6.0 that is associated to the Wi-Fi of a device that has no Internet access. Android keeps dropping the connection and won't even automatically reconnect after a few tries because it detects that there is no Internet access.
How can I force Android to keep the connection with this Wi-Fi even if there is no Internet access?
The device is not rooted, but I can change "things" programmatically in the application that actually picks up this Wi-Fi spot.
Edit #1
In my application, I'm currently using the enableNetwork API. The documentation states:
If an application's target SDK version is LOLLIPOP or newer, network communication may not use Wi-Fi even if Wi-Fi is connected; traffic may instead be sent through another network, such as cellular data, Bluetooth tethering, or Ethernet. For example, traffic will never use a Wi-Fi network that does not provide Internet access (e.g. a wireless printer), if another network that does offer Internet access (e.g. cellular data) is available. Applications that need to ensure that their network traffic uses Wi-Fi should use APIs such as bindSocket(java.net.Socket), openConnection(java.net.URL), or bindProcessToNetwork(Network) to do so.
In this particular case, the potential other network (cellular data) is off as the device is forced in plane mode.
回答1:
My gateway was not correct. False problem. See it for more information: https://android.stackexchange.com/questions/131132/force-marshmallow-to-keep-a-wi-fi-without-internet-access/
来源:https://stackoverflow.com/questions/34191536/android-marshmallow-how-to-avoid-wi-fi-drop-if-no-internet-access