How to eliminate exclamation points in the native Android network status and android exclamation points
Friends who like to use native Android systems may find that there is often an exclamation mark on their status bar signal icons.
What's going on? This is because Android uses a captive detection method to detect the network status.
In fact, it is very simple. when connected to a network, such as a mobile data network or WIFI, the Android NetworkMonitor module constructs an http request and sends it to the specified server, then, use the received response to determine the network status.
The network status is as follows:
1) there is no return at all. In this case, there is no Internet access. See figure 1.
2) return status code 204, which indicates full Internet access (a specific server returns a status code of 204). See figure 1.
3) Other status codes except 204 are greater than 200 and less than 400. This status code generally indicates a network connection for Web login, for example, a network provided by an airport or mall that requires text message login. In this case, Android constructs a status bar notification that may require logon to notify users that login may be required. See figure 2.
The default server address accessed by the Android system is:
Http://clients3.google.com/generate_204
Fortunately, thanks to the Great Wall, this address is inaccessible in China, so there is always no return value. In this case, Android always considers that there is no Internet access capability, so an exclamation point is displayed on the signal icon.
In fact, we can access the network at this time. To eliminate such misjudgment, We can roughly disable this function and use the following adb command:
[Note: This method is not recommended. It is not recommended to execute this command]
$ adb shell settings put global captive_portal_detection_enabled 0
However, there is a major problem with this approach: When you encounter a network that needs to log on, you cannot be identified, so you cannot be prompted to log on to the web.
Therefore, it is best to provide a website that can be accessed to specifically return the 204 status code and then direct the detection server to this address.
Here, I will provide you with a network detection server address:
Http://www.androidbak.net/generate_204
You can use the following adb command to modify the server address:
$ adb shell settings put global captive_portal_server www.androidbak.net
If you do not want to use it after using it, you can use the following command to restore the initial state:
$ adb shell settings delete global captive_portal_server$ adb shell settings put global captive_portal_detection_enabled 1