My app needs to communicate with a Sony Wifi camera. The user specifies the camera Wifi SSID and password, the app connects, takes a picture and retrieves it to the android device. When the app is done taking pictures, I want it to restore the Wifi connection (if any) that existed before the app was started. E.g. the user may have been connected to to a coffee shop hotspot when she starts the wifi camera app, and so the the app should automatically reconnect to the hotspot when it's done.
To restore the pre-existing connection, the app needs to know the SSID - and also the password, I think. It's easy for the app to determine the pre-existing SSID - just call WifiManager.getConnectionInfo().getSSID() before switching to the camera Wifi SSID. But how to get the pre-existing password? I don't want to require the user to re-enter that password. Is this functionality possible?
Thanks, Tom
You can use the WifiInfo.getNetworkId
API to get current network id and save it for future use.
When you want to connect back to original network use WifiManager.enableNetwork
API and pass the network ID you cached before.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With