Objective:
When using some apps, such as Google Play, when not connected to the network, the app will automatically jump to the system's own WiFi connection interface (such as), in this interface to connect WiFi has a good feature: When the WiFi hotspot is not connected, the "next" button is not clickable, This experience is very good and ensures that a network is available in the next step.
Implementation steps:
1. How can I jump to this interface? (Action,log below when viewing Google Play jump via adb logcat)
I/activitymanager (444): START u0 {act=android.net.wifi.pick_wifi_network Cmp=com.android.settings/.wifi. Wifipickeractivity (have extras)} from PID 6972
2. With the log is simple, intent issued the above action is OK, the code is as follows:
Intent Intent = new Intent () intent.setaction ("Android.net.wifi.PICK_WIFI_NETWORK"); StartActivity (Intent);
The effect is as follows:
3. Wipe! Why is there a two button missing? After analysis Settings source code (Settings\src\com\android\settings\wifi\wifisettings.java and Wifipickeractivity.java) found the following information:
private static final String Extra_prefs_show_button_bar = "Extra_prefs_show_button_bar";//whether the button BAR is displayed, The pass value is true if the private static final String Extra_prefs_set_next_text = "Extra_prefs_set_next_text" is displayed, and/or the name of the custom button is not passed, The default is the next private static final String Extra_prefs_set_back_text = "Extra_prefs_set_back_text";//The name of the custom button, if not passed, The default is the previous step private static final String Extra_enable_next_on_connect = "wifi_enable_next_on_connect";// Whether to turn on network connection detection (if WiFi is connected, the Next button can be clicked)
lie down! Originally intent to carry the above extra information ah, OK, modify the code as follows:
Intent Intent = new Intent () intent.setaction ("Android.net.wifi.PICK_WIFI_NETWORK"); Intent.putextra ("Extra_prefs_ Show_button_bar ", true);//intent.putextra (" Extra_prefs_set_next_text "," done "); Intent.putextra ("Extra_prefs_set_back_text", "return"); Intent.putextra ("Wifi_enable_next_on_connect", true); StartActivity (Intent);
jump, the effect is like the beginning of the picture, the same, haha!