I’m using HttpClient to post then retrieve something in Android, which works great, but when I dont have a internet connection it forces close, is their a way to catch UnknownHostException when making an HttpPost? I know I could make sure its connected to the internet before making the request, but what about if the phone just doesn’t have service?
I’m using HttpClient to post then retrieve something in Android, which works great, but
Share
UnknownHostException is a Subclass of IOException, so you should be able to catch/manage it simply catching IOException or something more specific (NoRoute, ConnectTimeout, etc.)
Also consider adding connection check before doing network calls with
ConnectivityManager