Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- new ReadJSONFeedTask().execute(
- //"http://extjs.org.cn/extjs/examples/grid/survey.html"
- "https://maps.googleapis.com/maps/api/elevation/json?locations=39.7391536,-104.9847034&key=myDEBUGkeygoeshere..."
- );
- private class ReadJSONFeedTask extends AsyncTask<String, Void, String> { //-- Line 113
- protected String doInBackground(String... urls) {
- return readJSONFeed(urls[0]);
- }
- protected void onPostExecute(String result) {
- Log.i("JSON","Result: " + result);
- try {
- JSONArray jsonArray = new JSONArray(result); //-- Line 121
- Log.i("JSON","Number of objects in feed: " + jsonArray.length());
- //--- Print out the content of the json feed---
- for (int i = 1; i < jsonArray.length(); i ++) {
- JSONObject jsonObject = jsonArray.getJSONObject(i);
- Toast.makeText(getBaseContext(), jsonObject.getString("elevation"),Toast.LENGTH_SHORT).show();
- }
- } catch (Exception e) {
- e.printStackTrace();
- Log.i("JSON","Error");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement