Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Priority for wifi configuration in android

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.

like image 725
user1699512 Avatar asked Nov 12 '22 03:11

user1699512


1 Answers

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.
like image 87
Arun Sivaramakrishnan S Avatar answered Nov 14 '22 23:11

Arun Sivaramakrishnan S