I have an application where I need connect to a network provided by a device developed by me. The device provides a WiFi network that has a fixed prefix (e.g. "AAB").
Is it possible to limit the available WiFi networks to networks that contains my prefix? This way, I can only choose one of them to connect.
Currently, I just create an Intent
for ACTION_PICK_WIFI_NETWORK
, which shows me all available network:
startActivity( new Intent( WifiManager.ACTION_PICK_WIFI_NETWORK ) );
As given here, you can search for all the available WiFi connections and filter them on basis of their IDs, or in your case, check if they start with the prefix or not.
Referencing the code from post above for quick overview:
WifiManager wifiManager = (WifiManager)
context.getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
String ssid = wifiInfo.getSSID();
int networkid = wifiInfo.getNetworkId();
Toast.makeText(context, "OK " + ssid, Toast.LENGTH_LONG).show();
Toast.makeText(context, "Network ID " + networkid,
Toast.LENGTH_LONG).show();
You can also use the BSSID as a unique identifier
Hope this helps.