I am using eclipse and the problem is that my httpConnection code is works for android 2.3.3. but it is not working for android 5.0 I cannot handle it.
private InputStream OpenHttpConnection(String urlString) throws IOException{
InputStream in = null;
int response = -1;
URL url = new URL(urlString);
URLConnection conn = url.openConnection();
if(!(conn instanceof HttpURLConnection))
throw new IOException("Not an HTTP connection");
try{
HttpURLConnection httpConn = (HttpURLConnection) conn;
httpConn.setRequestMethod("GET");
httpConn.connect();
response = httpConn.getResponseCode();
if(response == HttpURLConnection.HTTP_OK){
in = httpConn.getInputStream();
}
}
catch(Exception ex){
throw new IOException ("Error connecting");
}
return in;
}
It gives me "Error connecting" on android 5.0 also android 4.0.3.