user1699512
user1699512

Reputation: 141

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.

Upvotes: 5

Views: 9037

Answers (3)

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.

Upvotes: 2

cguest
cguest

Reputation: 71

I know this is probably a bit late, but I've been looking at the same thing, and apparently 99 999 is the highest value you can set, anything higher than that gets ignored From here

Upvotes: 0

Oleksandr Kravchuk
Oleksandr Kravchuk

Reputation: 6319

If I remember correctly, changes to pre-configured networks should be saved to make an effect.

addOrUpdateNetworkNative(WifiConfiguration config);

Upvotes: 0

Related Questions