Set or View “Advanced Wi-fi” Settings programatically

梦想与她 提交于 2019-12-19 02:54:28

问题


I need a way to open the "Advanced wifi" settings programatically to let the user change some of the settings, or, preferably, to change these advanced wireless settings programatically.

I can only access the wi-fi settings so far via startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS)) but not the advanced settings.

Is there a way to open the "Advanced wifi" settings?


回答1:


There are two more settings that might work for you:

From the API documentation:

  • Settings.ACTION_WIRELESS_SETTINGS

    startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS));
    
  • Settings.ACTION_WIFI_IP_SETTINGS

    startActivity(new Intent(android.provider.Settings.ACTION_WIFI_IP_SETTINGS));
    

Try those two and see if they open what you're after.




回答2:


Here is the code snippet to open WIFI settings page

Intent intent = new Intent(Intent.ACTION_MAIN, null);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    ComponentName cn = new ComponentName("com.android.settings", "com.android.settings.wifi.WifiSettings");
    intent.setComponent(cn);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity( intent);


来源:https://stackoverflow.com/questions/18388948/set-or-view-advanced-wi-fi-settings-programatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!