Android Network is unreachable - ENETUNREACH

后端 未结 4 801
盖世英雄少女心
盖世英雄少女心 2021-02-01 19:52

I\'m having a weird error on my android application. I\'m testing with a local server using Xampp. The App is to retrieve records from a Database and store them in the phone.

相关标签:
4条回答
  • 2021-02-01 20:06

    You can also add a check for internet connection before making any request so that user will get to know internet is not there.

    Use below code and if it return false show Toast/Alert.

    private boolean isNetworkAvailable() {
    ConnectivityManager connectivityManager 
          = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
    return activeNetworkInfo != null && activeNetworkInfo.isConnected();
    }
    
    0 讨论(0)
  • 2021-02-01 20:08

    Have a case when my app is connecting then turn off wifi > app crash and it cannot go inside catch command Exception.

    0 讨论(0)
  • 2021-02-01 20:09

    please check Internet/WiFi connection on the device

    0 讨论(0)
  • 2021-02-01 20:14

    I've figured out what was the problem! The Samsung Fame wasn't connected to the Wi-Fi. It had no internet.

    0 讨论(0)
提交回复
热议问题