Thanks @Monika nd @Simon_K . Yes, it is not possible to test on different networks on emulators. One has to test it on Real device. In Java, to get the current network settings:
driver.getNetworkConnection();
And to set the network settings below method could be used:
public void setNetworkConnection(boolean airplaneMode, boolean wifi, boolean data){
NetworkConnectionSetting connection = new NetworkConnectionSetting(airplaneMode, wifi, data);
driver.setNetworkConnection(connection);
System.out.println("Your current connection settings are :" + driver.getNetworkConnection());
}
Thanks,
Shanky