I have a method to check for internet connectivity within the device.The method always throws exception even though the mobile is connected to wifi/gprs. Do i need to add any
permission within xml or is the code gone wrong
public boolean checkConnectivity(String url) {
try{
HttpURLConnection conn = (HttpURLConnection)new URL(url).openConnection();
conn.setRequestMethod("HEAD");
if(conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
return true;
}else{
return false;
}
}catch(Exception e) {
System.out.println("myhttp exception");
return false;
}
}
Add this to the manifest file: