Setting Priority for wifi configuration in android

user1699512 picture user1699512 · Jun 15, 2013 · Viewed 8k times · Source

I have to set a priority for wifi configuration sothat I have to always connect to specified wifi network so that device ignores other available wifi in the region.

  configuration.priority = 100000; 

It is connecting to the last known connected wifi network and ignoring specified wifi network.

Answer

Arun Sivaramakrishnan S picture Arun Sivaramakrishnan S · Aug 11, 2015

If you are trying to set priority for a particular Wifi Configuration, you must use

config.priority = value;

WifiManager.updateNetwork(config);

and you should use the below api after updating

WifiManager.saveConfiguration();

I was able to set priority for my configured network.

Note:

  • By default the android system will provide highest priority for the last known connected wifi network. If you want to set a higher priority for any other configuration, set the value with respect to the highest value set by the android system rather going for some numerical digit.
  • Default priority value is in relative with the highest value and its also based on its usage preference. User set value will be changed if the network is manually selected.