I'm trying to connect Android 10 to WiFi.
I tried WifiNetworkSuggestion, WifiNetworkSpecifier, NetworkCallback... And it is anoying because you have to wait for some kind of operative system notification, and in some cases it takes so long or it does not show up and you never connect to it. See image:
Android network suggestion notification
So I decided to see how WiFi apps are dealing with Android 10 deprecated Apis. I found out some. And they show me this panel when trying to enable WiFi.
Yes, this panel shows up when executing wifiManager.setWifiEnable(true) or (false) but, this method is deprecated in API 29, and I am using a phone with API 29 (Android 10, Q). How can I trigger this panel though? Maybe some intents? I tried:
startActivityForResult(new Intent(Settings.Panel.ACTION_INTERNET_CONNECTIVITY), INTERNET_SETTINGS_REQUEST);
It shows this. See image:
ACTION_INTERNET_CONNECTIVITY intent
But it is not what I'm looking for. So I been looking for days a better way to connect to WiFi without WifiNetworkSuggestion, WifiNetworkSpecifier, NetworkCallback in Android 10. I will show you an app that connects to WiFi instantly without any of WifiNetwork classes of above. See video
I solved for a while changing the targetSdkVersion to 28. I was using 29.
The problem now is that, since 2 of November of 2020, you can no longer upload your app targeting SDK 28. So now we are forced to use Network Suggestions.