Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. new ReadJSONFeedTask().execute(
  2. //"http://extjs.org.cn/extjs/examples/grid/survey.html"
  3. "https://maps.googleapis.com/maps/api/elevation/json?locations=39.7391536,-104.9847034&key=myDEBUGkeygoeshere..."
  4. );
  5.  
  6. private class ReadJSONFeedTask extends AsyncTask<String, Void, String> { //-- Line 113
  7. protected String doInBackground(String... urls) {
  8. return readJSONFeed(urls[0]);
  9. }
  10.  
  11. protected void onPostExecute(String result) {
  12. Log.i("JSON","Result: " + result);
  13. try {
  14. JSONArray jsonArray = new JSONArray(result); //-- Line 121
  15. Log.i("JSON","Number of objects in feed: " + jsonArray.length());
  16. //--- Print out the content of the json feed---
  17. for (int i = 1; i < jsonArray.length(); i ++) {
  18. JSONObject jsonObject = jsonArray.getJSONObject(i);
  19. Toast.makeText(getBaseContext(), jsonObject.getString("elevation"),Toast.LENGTH_SHORT).show();
  20. }
  21. } catch (Exception e) {
  22. e.printStackTrace();
  23. Log.i("JSON","Error");
  24. }
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement