I am trying to set up a test for automation on a new Android application that I am developing, but have few problems with one of the apis
The problem I am facing is that I want to start the test. AFTER Wi-Fi has a connection, not when it is in a connected state. I tried two solutions, but no luck, and the test seems to start before my Android device is fully connected (no x on vinyl tablets)
wifiManager.setWifiEnabled(state); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); while (wifiInfo.getSSID() == null) { Log.i("WifiStatus", "Here I am"); Thread.sleep(Time.ONE_SECOND); wifiInfo = wifiManager.getConnectionInfo();
This is my first implementation trying to get an SSID to determine if a connection has been established. but the test still starts before the full connection is complete and the setup is not completed.
ConnectivityManager connManager = (ConnectivityManager) con.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); wifiManager.setWifiEnabled(state); while (!networkInfo.isConnected()) { Log.i("WifiStatus", "Here I am"); Thread.sleep(Time.ONE_SECOND); networkInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); }
Second implementation: Instead, I use the connection manager and using isConnected() .
Does anyone have another method that I can check to determine if Wi-Fi is fully connected?
source share