Hi Frnds,
I wanna to write a prog to check whether internet is connected or not.
I tried using URL api or pinging Google
but in both the cases i was not satisfied with the solution.
can anyone provide me any other way to solve this prob.
Printable View
Hi Frnds,
I wanna to write a prog to check whether internet is connected or not.
I tried using URL api or pinging Google
but in both the cases i was not satisfied with the solution.
can anyone provide me any other way to solve this prob.
I tried with the following solution
public boolean getConnectivityStatus(String urlAddress) {
boolean connStatus = false;
try {
URL url = new URL(urlAddress);
URLConnection conn = url.openConnection();
conn.connect();
connStatus = true;
} catch (MalformedURLException e) {
connStatus = false;
System.out.println("MalformedURLException");
e.printStackTrace();
} catch (IOException e) {
connStatus = false;
System.out.println("IOException");
e.printStackTrace();
}
return connStatus;
}
can anyone provide me any other solution