WiFiFlutter
WiFiFlutter copied to clipboard
[wifi_iot] Android 11 use "WiFiForIoTPlugin.connect(ssid,pw)" can not "real" connect
Android 11 XiaoMi A1
When I press connect button in wifi_iot Example, popup a dialog "wants to use a temporary WIFI net work in your device.....", And When I connect,and toast connection sucessful, but I can not see a wifi icon in Android Native Status Bar In Settings-WIFI, this connected WIFI item-summary show "Connected via router" And Unable to access the internet But When I connect this WIFI by maunal,Android Native Status Bar show icon and I can access the internet
Permission
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.UPDATE_DEVICE_STATS" />
<uses-permission android:name="android.permission.INTERNET" />
Looking forward to recovery,Thank you!
I'm also face this problem.
I have the same issue using the code below
try { if (await Permission.location.request().isGranted) { await WiFiForIoTPlugin.connect(state.evWifiName, password: state.evWifiPassword, joinOnce: false, security: NetworkSecurity.WPA) .then((value) async { if (value) { WiFiForIoTPlugin.forceWifiUsage(false); } }); } } catch (e) { print(e); print('error occurred'); }
I have tried setting withInternet:true
however every time I do this, nothing happens but I get status 0
in the console. Any thoughts?
See comment in #346 Looks like on Android you have to use "findAndConnect" and then forceWifi.
Hello @kodejack , I appreciate your suggestion, and I did try using "findAndConnect," which did work. However, I'm encountering a different issue. In my case, I'm already connected to a Wi-Fi network (let's call it "X") outside the app, and "findAndConnect" does not disconnect the device from "X" and connect it to my desired network.
I've attempted the following
:Using the "disconnect" function, but it's returning "false" for some reason.
:Fetching the SSID using "getSSID" and attempting to remove the network. However, I could fetch the SSID but couldn't disconnect using "removeWifiNetwork.
"To clarify, my goal is to connect to a particular network (let's call it "Y"). If we are already connected to "X," I want to disconnect from that network and connect to "Y."
Thank you for your assistance.