With the release of Android 5.1, it looks like all the Apache http stuff has been deprecated. Looking at the documentation is useless; they all say
This class
Call webservice httpclient replace by httpurlconnection
my code here
public static String getDataFromUrl(String url) {
String result = null;
// System.out.println("URL comes in jsonparser class is: " + url);
try {
URL myurl=new URL(url);
HttpURLConnection urlConnection = (HttpURLConnection) myurl
.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.setDoInput(true);
urlConnection.connect();
InputStream is=urlConnection.getInputStream();
if (is != null) {
StringBuilder sb = new StringBuilder();
String line;
try {
BufferedReader reader = new BufferedReader(
new InputStreamReader(is));
while ((line = reader.readLine()) != null) {
sb.append(line);
}
reader.close();
} finally {
is.close();
}
result = sb.toString();
}
}catch (Exception e){
result=null;
}
return result;
}