androidjsonandroid-volleyunknown-host

java.net.UnknownHostException error while using volley json android


I am using Volley Json to connect my android app to web sever. It works fine at normal time. But when there is no connection while connecting the server, it toast "java.net.UnknownHostException: Unable to resolve host "www.example.com":No address associated with hostname". The app does not crush but as it show UnknownHostException error toast, it can probably annoy user. How can I hide that toast or handle that error. Please answer me.


Solution

  • Just comment out the toast statement inside

    @Override
     public void onErrorResponse(VolleyError error) {
    //Toast.makeToast(this,"toast",Toast.LENGTH_SHORT).show();
      }