0

I am trying to connect on WPA-PSK secured network on android devices. The network is already configured to the device manually just disconnected. I got this kind of solution working on older devices. How do I connect to a specific Wi-Fi network in Android programmatically?

But it won't work on android 6.0

I found that wificonficurations can not be anymore modified in android 6.0 so does this mean it is not even possible to do this on the android 6.0. or would this kind of approach make it work. http://www.intentfilter.com/2016/08/programatically-connecting-to-wifi.html I am just trying to figure is it even possible to connect programmatically in wifi on android 6.0 and above. If it requires runtime permission it's fine for my solution.

thankyou in advance

wpj
  • 206
  • 2
  • 14

1 Answers1

0

I managed to get it working problem was this bug in 6.0.1 so that enable network just gets stuck reason was that wifiManager.enableNetwork(); gets stuck ifwifiManager.addNetwork(); returns -1 https://issuetracker.google.com/issues/37069571 workaround was to add network manually and then get the network id from wifiManager.getConfiguredNetworks(); and call enableNetwork(); with proper id.

still unclear why adding network configuration always returns -1

wpj
  • 206
  • 2
  • 14
  • reason was that adding fails if the network has been added before by another app or user. So that's what the change for 6.0 means about configuration not allowed to be modified. – wpj May 24 '17 at 11:48