Stay organized with collections
Save and categorize content based on your preferences.
On Android 11 (SDK level 30) and higher, apps can use the
android.provider.Settings.ACTION_WIFI_ADD_NETWORKS
intent to guide the user through adding one or more new saved networks or
Passpoint configurations. The API also works as-is to modify existing saved
configurations.
To save a network or Passpoint configuration, do the following:
Create an ACTION_WIFI_ADD_NETWORKS intent.
Create one or more configurations using
WifiNetworkSuggestion.Builder.
Note that even though you use a WifiNetworkSuggestion, this Intent API is
not related to the Suggestion API.
Create a parcelable array list of the configurations and attach it to the
intent with the
EXTRA_WIFI_NETWORK_LIST
extra.
If the resultCode is RESULT_OK, then the data Intent contains the
EXTRA_WIFI_NETWORK_RESULT_LIST
extra, which contains an array of result codes indicating whether individual
configurations were saved successfully. The possible result codes are:
If the request is successful, the platform triggers a connection to one of the
newly saved networks.
Code sample
The following code sample shows how to save a network or Passpoint
configuration.
classMainActivity:AppCompatActivity(){overridefunonCreate(savedInstanceState:Bundle?){super.onCreate(savedInstanceState)...}funstartOperation(){valsuggestions=ArrayList<WifiNetworkSuggestion>()// WPA2 configurationsuggestions.add(WifiNetworkSuggestion.Builder().setSsid("test111111").setWpa2Passphrase("test123456").build())// Open configurationsuggestions.add(WifiNetworkSuggestion.Builder().setSsid("test222222").build())// Passpoint configurationvalconfig=PasspointConfiguration()config.credential=Credential().apply{realm="realm.example.com"simCredential=Credential.SimCredential().apply{eapType=18imsi="123456*"}}config.homeSp=HomeSp().apply{fqdn="test1.example.com"friendlyName="Some Friendly Name"}suggestions.add(WifiNetworkSuggestion.Builder().setPasspointConfig(config).build())// Create intentvalbundle=Bundle()bundle.putParcelableArrayList(EXTRA_WIFI_NETWORK_LIST,suggestions)valintent=Intent(ACTION_WIFI_ADD_NETWORKS)intent.putExtras(bundle)// Launch intentstartActivityForResult(intent,0)}overridefunonActivityResult(requestCode:Int,resultCode:Int,data:Intent?){super.onActivityResult(requestCode,resultCode,data)if(resultCode==RESULT_OK){// user agreed to save configurations: still need to check individual resultsif(data!=null && data.hasExtra(EXTRA_WIFI_NETWORK_RESULT_LIST)){for(codeindata.getIntegerArrayListExtra(EXTRA_WIFI_NETWORK_RESULT_LIST)){when(code){ADD_WIFI_RESULT_SUCCESS->
...// Configuration saved or modifiedADD_WIFI_RESULT_ADD_OR_UPDATE_FAILED->
...// Something went wrong - invalid configurationADD_WIFI_RESULT_ALREADY_EXISTS->
...// Configuration existed (as-is) on device, nothing changedelse->
...// Other errors}}}}else{// User refused to save configurations}}}
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-08-20 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-20 UTC."],[],[],null,["# Save networks and Passpoint configurations\n\nOn Android 11 (SDK level 30) and higher, apps can use the\n[`android.provider.Settings.ACTION_WIFI_ADD_NETWORKS`](/reference/android/provider/Settings#ACTION_WIFI_ADD_NETWORKS)\nintent to guide the user through adding one or more new saved networks or\nPasspoint configurations. The API also works as-is to modify existing saved\nconfigurations.\n| **Note:** This API is the closest in functionality to the deprecated `WifiManager.addNetwork(WifiConfiguration config)` API, in that the resulting configuration is added to the user-facing and managed saved network and subscription list.\n\nTo save a network or Passpoint configuration, do the following:\n\n1. Create an `ACTION_WIFI_ADD_NETWORKS` intent.\n\n2. Create one or more configurations using\n [`WifiNetworkSuggestion.Builder`](/reference/android/net/wifi/WifiNetworkSuggestion.Builder).\n Note that even though you use a `WifiNetworkSuggestion`, this Intent API is\n not related to the [Suggestion API](/develop/connectivity/wifi-suggest).\n\n3. Create a parcelable array list of the configurations and attach it to the\n intent with the\n [`EXTRA_WIFI_NETWORK_LIST`](/reference/android/provider/Settings#EXTRA_WIFI_NETWORK_LIST)\n extra.\n\n4. Execute\n [`Activity.startActivityForResult()`](/reference/android/app/Activity#startActivityForResult(android.content.Intent,%20int)),\n passing in the intent.\n\n5. Listen for the result using the\n [`Activity.onActivityResult()`](/reference/android/app/Activity#onActivityResult(int,%20int,%20android.content.Intent))\n callback.\n\n The `resultCode` can be one of the following:\n - [`Activity.RESULT_OK`](/reference/android/app/Activity#RESULT_OK): indicating that the user accepted the proposed networks and saved them.\n - [`Activity.RESULT_CANCELED`](/reference/android/app/Activity#RESULT_CANCELED): indicating that the user rejected the proposed networks.\n\n If the `resultCode` is `RESULT_OK`, then the data `Intent` contains the\n [`EXTRA_WIFI_NETWORK_RESULT_LIST`](/reference/android/provider/Settings#EXTRA_WIFI_NETWORK_RESULT_LIST)\n extra, which contains an array of result codes indicating whether individual\n configurations were saved successfully. The possible result codes are:\n - [`ADD_WIFI_RESULT_SUCCESS`](/reference/android/provider/Settings#ADD_WIFI_RESULT_SUCCESS): configuration added or successfully updated.\n - [`ADD_WIFI_RESULT_ADD_OR_UPDATE_FAILED`](/reference/android/provider/Settings#ADD_WIFI_RESULT_ADD_OR_UPDATE_FAILED): failure when trying to add configuration, such as due to a badly formed configuration.\n - [`ADD_WIFI_RESULT_ALREADY_EXISTS`](/reference/android/provider/Settings#ADD_WIFI_RESULT_ALREADY_EXISTS): the requested configuration already existed so no action was necessary.\n6. If the request is successful, the platform triggers a connection to one of the\n newly saved networks.\n\nCode sample\n-----------\n\nThe following code sample shows how to save a network or Passpoint\nconfiguration. \n\n class MainActivity : AppCompatActivity() {\n override fun onCreate(savedInstanceState: Bundle?) {\n super.onCreate(savedInstanceState)\n ...\n }\n\n fun startOperation() {\n val suggestions = ArrayList\u003cWifiNetworkSuggestion\u003e()\n\n // WPA2 configuration\n suggestions.add(\n WifiNetworkSuggestion.Builder()\n .setSsid(\"test111111\")\n .setWpa2Passphrase(\"test123456\")\n .build()\n )\n\n // Open configuration\n suggestions.add(\n WifiNetworkSuggestion.Builder()\n .setSsid(\"test222222\")\n .build()\n )\n\n // Passpoint configuration\n val config = PasspointConfiguration()\n config.credential = Credential().apply {\n realm = \"realm.example.com\"\n simCredential = Credential.SimCredential().apply {\n eapType = 18\n imsi = \"123456*\"\n }\n }\n config.homeSp = HomeSp().apply {\n fqdn = \"test1.example.com\"\n friendlyName = \"Some Friendly Name\"\n }\n suggestions.add(\n WifiNetworkSuggestion.Builder()\n .setPasspointConfig(config)\n .build())\n\n // Create intent\n val bundle = Bundle()\n bundle.putParcelableArrayList(EXTRA_WIFI_NETWORK_LIST, suggestions)\n val intent = Intent(ACTION_WIFI_ADD_NETWORKS)\n intent.putExtras(bundle)\n\n // Launch intent\n startActivityForResult(intent, 0)\n }\n\n override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {\n super.onActivityResult(requestCode, resultCode, data)\n if(resultCode == RESULT_OK) {\n // user agreed to save configurations: still need to check individual results\n if (data != null && data.hasExtra(EXTRA_WIFI_NETWORK_RESULT_LIST)) {\n for (code in data.getIntegerArrayListExtra(EXTRA_WIFI_NETWORK_RESULT_LIST)) {\n when (code) {\n ADD_WIFI_RESULT_SUCCESS -\u003e\n ... // Configuration saved or modified\n ADD_WIFI_RESULT_ADD_OR_UPDATE_FAILED -\u003e\n ... // Something went wrong - invalid configuration\n ADD_WIFI_RESULT_ALREADY_EXISTS -\u003e\n ... // Configuration existed (as-is) on device, nothing changed\n else -\u003e\n ... // Other errors\n }\n }\n }\n } else {\n // User refused to save configurations\n }\n }\n }"]]