Android 7及之后的版本输入如下两个命令:
adb shell “settings put global captive_portal_http_url http://www.google.cn/generate_204”
adb shell “settings put global captive_portal_https_url https://www.google.cn/generate_204”
7之前的版本运行如下的命令:
adb shell “settings put global captive_portal_serverhttp://www.google.cn/generate_204”
可以输入如下命令, 禁止检测网络连接状态.
adb shell settings put global captive_portal_detection_enabled 0
可以输入如下命令, 打开检测网络连接状态.
adb shell settings put global captive_portal_detection_enabled 1
原理:让 Android 访问 https://www.google.cn/generate_204,只要返回 204 状态代码,就判定为网络通畅。
而用 Nginx 架设 204 返回也很简单:
location /generate_204 {
return 204;
}