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.
Asked
Active
Viewed 2,254 times
-3
-
post some code..!! – Janki Gadhiya May 19 '16 at 08:32
2 Answers
3
Just comment out the toast statement inside
@Override
public void onErrorResponse(VolleyError error) {
//Toast.makeToast(this,"toast",Toast.LENGTH_SHORT).show();
}

Zeeshan Shabbir
- 6,704
- 4
- 38
- 74
-
-
1use broadcast receiver when internet is connection is on. It will notify the activity then do your work that you want to do. – Zeeshan Shabbir Nov 16 '16 at 14:32
-
-
1check this answer and other answers in this threat http://stackoverflow.com/a/26114247/5275639 – Zeeshan Shabbir Nov 17 '16 at 05:37
-
@ Zeeshan Shabbir : Thank you so much for your help. :) you deserve +1. – Jignesh M. Mehta Nov 17 '16 at 05:41
-
1
1
This is happening due to the internet connection error. If the internet connection is not there error listener get activated and it show the toast message. if you don't want that toast message just remove it in error listener.

Sindujan Nirmalan
- 470
- 1
- 8
- 18