1

I tried to check Internet Connectivity in my App to handle if there is no internet with this code. It always returns true with Wi-Fi type.

ConnectivityManager connMgr = (ConnectivityManager)
                getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();

        if (networkInfo != null && networkInfo.isConnected()) {
            System.out.println(  networkInfo.getTypeName());
            Loading_News();
        }
Yun
  • 3,056
  • 6
  • 9
  • 28
coding
  • 11
  • 1
  • This may help: https://stackoverflow.com/questions/54527301/connectivitymanager-networkcallback-onavailablenetwork-network-method-is/66572922#66572922 – Sam Chen Sep 19 '21 at 14:47

0 Answers0