I have a decive which reads data from serial and tranmits it over WiFi. (there is no global internet connection). It has an IP and port to which it can forward the read data over socket connection. Now I have an android application which needs to connect to the device (lets call it D) using its ssid and presharedkey so that I can initiate socket connection and read data from device D.
This works fine if there is only one WiFi AP (i.e. device D) but in case mobile is connected to another WiFi then when I try to connect (via code similar to https://stackoverflow.com/a/8818490/504133) mobile connects to Device D WiFi for a moment and then gets connected to previously connected WiFi automatically.
How can I auto Connect to specific WiFi AP in presence of other remembered strong WiFi connections via code ? (I have tried setting priority for WiFiConfiguration but it still does not work)