what will be the best solution for the case stated below whether the user has active internet connection or not( by active i mean that user can open any web URl).
- By making http request to google.com and check the respose code, or
HttpURLConnection urlc = (HttpURLConnection) (new URL("http://clients3.google.com/generate_204") .openConnection()); urlc.setRequestProperty("User-Agent", "Android"); urlc.setRequestProperty("Connection", "close"); urlc.connect(); Log.d("reqcode",""+urlc.getResponseCode()); return (urlc.getResponseCode() == 204 && urlc.getContentLength() == 0);
- by making a request to the server which i am using.
and which is best in terms of performance.