Android Rookie note-wifipickeractivity implementation jump to system comes with WiFi connection interface

Source: Internet
Author: User

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!



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.