Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wifi.findAndConnect(ssid,password) not working in android version 8+ #106

Open
nikhilsmg opened this issue Jun 16, 2020 · 5 comments
Open

Comments

@nikhilsmg
Copy link

In android version <8 works fine. but in the latest versions 9, 10. it's not working.
Any solution?

@digimatt22
Copy link

@nikhilsmg I don't know if you found an answer to your issue but I am using the library on android version greater than 8. I would guess that you need to enabled course location (or fine location) permission as I believe this requirement was added around version 8 and could be the reason you are unable to successfully connect.

@verybluebot
Copy link

verybluebot commented Jan 3, 2021

A bit off topic, but API level 29 and above (android 10+) has deprecated a lot of the connection method used here. Any upcoming pull requests to fix that?
https://developer.android.com/about/versions/10/privacy/changes#configure-wifi

the problematic code is in connectTo() method from what I have noticed:

// If network not already in configured networks add new network
if ( updateNetwork == -1 ) {
	    updateNetwork = wifi.addNetwork(conf);
	    wifi.saveConfiguration();
}

// if network not added return false
	// TODO: addNetwork() will always return -1 in API 29 and above
if ( updateNetwork == -1 ) {
	return false;
}

   // disconnect current network
	// TODO: disconnect() will always return false in API 29 and above

	boolean disconnect = wifi.disconnect();
if ( !disconnect ) {
	return false;
}

   // enable new network
	// TODO: enableNetwork() will always return false in API 29 and above
	boolean enableNetwork = wifi.enableNetwork(updateNetwork, true);
if ( !enableNetwork ) {
	return false;
}

@chilidoggca
Copy link

@nikhilsmg I don't know if you found an answer to your issue but I am using the library on android version greater than 8. I would guess that you need to enabled course location (or fine location) permission as I believe this requirement was added around version 8 and could be the reason you are unable to successfully connect.

For us, the feature broke on android 10+ phones after upgrading our app target sdk version from API Level 28 to 29, in compliance with Play Store. It still works on older android OS phones. We have always requested ACCESS_FINE_LOCATION permission, so it is not the issue.

@jdoavila
Copy link

Hi, anyone have a solution for this issue? I have the same problem in API 30, found always return false.

@monkin77
Copy link

I'm also facing the same issue. It would be of great help if there was a solution to this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants