0

We have a Wifi-connected device. We need to connect to the device via wifi for installation. Once connected, the application sends the request on a ip.

This works smoothly before android 9. But I'm having some problems when I do with android 9. Because when i connect to device i getting error message like this: wi-fi has no internet acces. And requests continue on mobile data. So app can't talk with device.

Can i doing something about this problem?

Mustafa Kuloğlu
  • 1,122
  • 1
  • 8
  • 16

1 Answers1

0

I guess this is related to permissions since API level 27 you need either

android.permission.ACCESS_FINE_LOCATION
or
android.permission.ACCESS_COARSE_LOCATION
permission.

You need to CHANGE_WIFI_STATE for Android Pie.
Try this

  ConnectivityManager connManager = (ConnectivityManager) activity.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo networkInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
        if (networkInfo.isConnected()) {
            WifiManager wifiManager = (WifiManager) activity.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
            WifiInfo wifiInfo = wifiManager.getConnectionInfo();
            wifiInfo.getSSID();
            String name = networkInfo.getExtraInfo();
            String ssid = "\"" + wifiInfo.getSSID() + "\"";
}

You can study about these changes in detail. Refer Here

  • Thanks for your answer. But i guess, i couldn't explain. App can connect with device via wifi. App can't send request via wifi when mobile data is open. Because there is no internet connection in the wifi source, so the system switched the internet source from wifi to mobile data. But if mobile data is not open, the only way to connect internet is wifi. So in this situation app can communicate with device. – Mustafa Kuloğlu Mar 28 '19 at 12:35