Programmatically connect Wifi password?

My application must communicate with the Sony Wifi camera. The user specifies the SSID and password of the Wi-Fi camera, the application connects, takes a snapshot and retrieves it on the Android device. When the application took a picture, I want it to restore the Wi-Fi connection (if any) that existed before the application was launched. For example. the user may have been connected to the access point in the coffee house when she launches the application for the Wi-Fi camera, and therefore the application should automatically connect to the access point when it is done.

To restore an existing connection, the application must know the SSID, as well as the password, I think. It is easy for an application to determine a pre-existing SSID - just call WifiManager.getConnectionInfo (). GetSSID () before switching to the WID SSID of the camera. But how to get an existing password? I do not want to require the user to re-enter this password. Is this feature possible?

Thanks Tom

+8
android android wifi
source share
1 answer

You can use the WifiInfo.getNetworkId API to get the current network ID and save it for future use. If you want to connect to the source network, use the WifiManager.enableNetwork API and pass in the network identifier that you previously cached.

+6
source share

All Articles