WifConfiguration stay connected to LocalOnly hotspot

I'm trying to use an Android App to connect to a temporary hotspot that is used to configure the wifi connected for a seperate device.

I've been able to connect to my temporary hotspot using this snippet

WifiConfiguration conf = new WifiConfiguration();
conf.SSID = "\"SetupNetwork\"";
conf.status = WifiConfiguration.Status.ENABLED;
int netId = wifiManager.addNetwork(conf);

The problem is that Android quickly realizes that this network doesn't have an internet connected and decides to "help" by automatically switching back to my old network.

I was considering using

conf.priority = 1

but priority is not present anymore in API 26.