The priority rules for the current Android WiFi auto-connect are as follows:
1, the priority value of the range is set to [0,1000000], if beyond this range will reset;
2, the most recently connected AP has the highest priority, in the automatic connection will first try to connect it;
3, not connected but scan to the AP, according to its signal value of the strength of the order, the stronger the display of the front, but, still have to synthesize
Security factors for APS, the basic situation is: WPA/WPA2 > WEP > Signal Level High > signal level low > Noise low > Noise
High
4. If the AP is preset, it may set its highest priority.
Check the source code path: frameworks/base/wifi/java/android/net/wifi/
Wificonfigstore.java
Boolean selectnetwork (int netId) {if (vdbg) locallog ("Selectnetwork", netId); if (netId = = invalid_network_id) return false; Reset the priority of each network at start or if it is goes too high. if (mlastpriority = =-1 | | mlastpriority > 1000000) {xlog.d (TAG, "need to reset", mlastpriority : "+ mlastpriority); For (Wificonfiguration config:mConfiguredNetworks.values ()) {if (Config.networkid! = invalid_network_id) {config.priority = 0; addorupdatenetworknative (config); }} mlastpriority = 0; }//Set to the highest and save the configuration. wificonfiguration config = new wificonfiguration (); Config.networkid = netId; config.priority = ++mlastpriority; addorupdatenetworknative (config); Mwifinative.saveconfig (); /* Enable the given network while disabling all other Networks */Enablenetworkwithoutbroadcast (netId, true); /* Avoid Saving the config & sending a broadcast to prevent settings * from displaying a disabled list of Netwo Rks */return true; }
Sometimes, we forget the password that has been connected to the WiFi, the application market also has the relevant application can help us to read. In fact, if you have root privileges, you can view it with the re file manager (Root Explorer). File path:
/data/misc/wifi/sockets/wpa_supplicant.conf
Each network package is a connected Wi-Fi hotspot, where the SSID is the name, PSK is the password, also you can see additional information, including encryption type KEY_MGMT and priority priorities, whether to automatically connect Autojoin, and so on, such as:
Reprint Please specify source: Zhou Mushi's csdn blog Http://blog.csdn.net/zhoumushui
My github: Zhou Mushi's GitHub Https://github.com/zhoumushui
Android Auto-connect WiFi priority rule and view password for connected WiFi