Open vb-star opened 3 years ago
This should not happen since we call .removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
which removes the requirement of the network to have internet.
@Niek I think we need to enforce the process to use this network, once conneted.
Can you add ConnectivityManager.setProcessDefaultNetwork(network);
in onAvailable
callback of networkCallback
and test if the captive portal still comes?
in this case also need to ConnectivityManager.setProcessDefaultNetwork(null);
in disconnect
.
@daadu that worked! thanks!
Do you want me to make a PR?
Yes, please file the PR, make sure ConnectivityManager.setProcessDefaultNetwork(null);
is called to clean up.
ConnectivityManager.setProcessDefaultNetwork
is deprecated and therefore not reliable.
Use connManger.bindProcessToNetwork
instead.
Infact this is what forceWifiUsage
does.
I think the "captive portal" wont come if you call that after connect.
But I think we should this internally, we have got lot of issues stating the same, after connect
, the network does not work, I ask them to call forceWifiUsage
explicitly.
Ahhhh.... this works indeed:
await WiFiForIoTPlugin.forceWifiUsage(true);
So there's no need for a PR... maybe this should be documented somewhere though.
can you please check it with android 9 also?
one more thing,
whether you add .removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
then is your internet is working out of the application in Android 10 onward?
Yes, internet outside of the app is working with withInternet: false
.
But it seems that once I disconnect from the SSID (for example back to the original SSID) I don't have internet anymore in the app. Outside the app it works fine - this is maybe related to #130.
whenever I tried it with my open wifi, yes I have connected to that open wifi but my internet is not working out of the application. is there any specific reason?
According to the docs the network connected, will only work with the application.
So will not have effect outside the app.
Ahhhh.... this works indeed:
await WiFiForIoTPlugin.forceWifiUsage(true);
So there's no need for a PR... maybe this should be documented somewhere though.
I suggest, this should happen out of the box, instead of documenting it somewhere.
I aware of that, I am also using this but My internet is not working out of the Application. yes, it's working only inner app.
Yes, internet outside of the app is working with
withInternet: false
.But it seems that once I disconnect from the SSID (for example back to the original SSID) I don't have internet anymore in the app. Outside the app it works fine - this is maybe related to #130.
This is because with enabling forceWifiUsage
(internally bindNetwork
), you need to make sure the bind is removed (properly cleaned up) with disabling it.
This is mandatory (to disable) according to docs, disconnecting will not release the bind.
is there any method for remove binding?
is there any method for remove binding?
forceWifiUsage(false)
oh.. sorry, Let me check with this.
Actually, I have done it with some modification in deprecate code and It's working well. My internet is working out of the application in Android 10 onward.
Same issue here. When manually connecting to the WiFi network, it works fine. When using
connect()/findAndConnect()
, all HTTP requests to internal IPs hang because of the captive portal check.