Created
November 11, 2013 09:57
-
-
Save david-batranu/7410768 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private class DownloadWebPageTask extends AsyncTask<String, Void, String> { | |
@Override | |
protected String doInBackground(String... urls) { | |
String result = new String(); | |
try { | |
URL location = new URL(url); | |
URLConnection connection = location.openConnection(); | |
BufferedReader data = new BufferedReader(new InputStreamReader(connection.getInputStream())); | |
String line; | |
while ((line = data.readLine()) != null) { | |
result = line; | |
} | |
} catch (MalformedURLException e) { | |
// TODO Auto-generated catch block | |
e.printStackTrace(); | |
} catch (IOException e) { | |
// TODO Auto-generated catch block | |
e.printStackTrace(); | |
} | |
return result; | |
} | |
@Override | |
protected void onPostExecute(String result) { | |
JSONObject json = new JSONObject(); | |
if(result != null){ | |
try { | |
json = new JSONObject(result); | |
} catch (JSONException e) { | |
// TODO Auto-generated catch block | |
e.printStackTrace(); | |
} | |
} | |
updateList(json); | |
((ArticleListingAdapter) getListAdapter()).notifyDataSetChanged(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment