0

I'm developing an app that configure several devices that the company develops. Each device opens an access point and, to configure it, I need to connect to each device.

I'm having a problem when there is many wifi networks available in the area, because my Android device keeps losing the connection with the device to configure, and that breaks the process. I've configured a Broadcast Receiver to reconnect to the device when loose the connection, but that isn't enough.

What I want to know is if there is a way to "ignore" all the networks available that isn't from a device to configure in order to improve my configuration process.

I'm sorry for the bad english. Thanks

1 Answers1

0

You can't hide networks in the android settings and starting with android 10 (targetsdk 29) you can't force a connection to a wifi from your app.

Devices with android 10 and higher can use the Wi-Fi suggestion API to automatically add credentials of a wifi to the system settings and show it as a suggested network. This will also create a notification: Example of a notification from the android Wi-Fi suggestion API

See the example here from my answer in another post:

// This only works with Android 10 and up (targetsdk = 29 and higher):
import android.net.wifi.WifiManager
import android.net.wifi.WifiNetworkSuggestion
...
val wifiManager = getSystemService(WIFI_SERVICE) as WifiManager
val networkSuggestion = WifiNetworkSuggestion.Builder()
    .setSsid("MyWifi")
    .setWpa2Passphrase("123Password")
    .build()
val list = arrayListOf(networkSuggestion)
wifiManager.addNetworkSuggestions(list)
Alexander Hoffmann
  • 5,104
  • 3
  • 17
  • 23