For Android, it is required that we ask permissions at runtime to make sure users understand better why en when permissions are needed. I know this is true for permissions l
Your permission is right but you have to check internet connectivity before using any internet related function . You can check internet connected or not by following function
public static boolean isNetworkOnline(Context con)
{
boolean status = false;
try
{
ConnectivityManager cm = (ConnectivityManager) con
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getNetworkInfo(0);
if (netInfo != null && netInfo.getState() == State.CONNECTED) {
status = true;
} else {
netInfo = cm.getNetworkInfo(1);
if (netInfo != null && netInfo.getState() == State.CONNECTED) {
status = true;
} else {
status = false;
}
}
} catch (Exception e) {
e.printStackTrace();
return false;
}
return status;
}