I would like to check if the android app has an internet connection available. I tried this could, which is not working due to the Googles requirement of https.
private static boolean netIsAvailable() {
try {
final URL url = new URL("http://www.google.com");
final URLConnection conn = url.openConnection();
conn.connect();
conn.getInputStream().close();
return true;
} catch (MalformedURLException e) {
throw new RuntimeException(e);
} catch (IOException e) {
Log.d(TAG, e.toString());
return false;
}
I am getting the error: java.io.IOException: Cleartext HTTP traffic to www.google.com not permitted
Which other ways there are?