private static URL createUrl(String stringUrl) {
    URL url = null;
    try {
	url = new URL(stringUrl);
    } catch (MalformedURLException exception) {
	Log.e("LOG_TAG", "Error with creating URL", exception);
	return null;
    }
    return url;
}


private class MyAsyncTask extends AsyncTask<URL, Void, Event> {

        @Override
	    protected Event doInBackground(URL... urls) {
            URL url = urls[0];
            String response = "";
            try {
                response = makeHttpRequest(url);
            } catch (Exception e) {

            }
            Event e = new Event(response);
            return e;
        }

        @Override
	    protected void onPostExecute(Event e) {
            if(e == null)
                return;
            updateUi(e);
        }

        private String readFromStream(InputStream inputStream) throws IOException {
            StringBuilder output = new StringBuilder();
            if (inputStream != null) {
                InputStreamReader isr = new InputStreamReader(inputStream, Charset.forName("UTF-8"));
                BufferedReader reader = new BufferedReader(isr);
                String line = reader.readLine();
                while (line != null) {
                    output.append(line);
                    line = reader.readLine();
                }
            }
            return output.toString();
        }

        private String makeHttpRequest(URL url) throws IOException {
            String response = "";
            HttpURLConnection urlConnection = null;
            InputStream inputStream = null;
            try {
                urlConnection = (HttpURLConnection) url.openConnection();
                urlConnection.setRequestMethod("GET");
                urlConnection.setReadTimeout(10000);
                urlConnection.setConnectTimeout(15000);
                urlConnection.connect();
                if (urlConnection.getResponseCode() == 200) {
                    inputStream = urlConnection.getInputStream();
                    response = readFromStream(inputStream);
                } else {
                    Log.e("LOG_TAG", "Get issues: " + urlConnection.getResponseMessage());
                }
            } catch (IOException e) {
                Log.e("LOG_TAG", "Problem getting earthquake JSON results");
            } finally {
                if (urlConnection != null) {
                    urlConnection.disconnect();
                }
                if (inputStream != null) {
                    inputStream.close();
                }
            }
            return response;
        }

}// end myAsyncTask Class
