Please download a current copy. I have modified it since the initial upload



Download 10.23 Kb.
Date21.06.2017
Size10.23 Kb.

IS 389 ANDROID HTTP AND THREAD LAB EKEDAHL

ABSTRACT


In this lab you will:

  • Work with various XML in-memory classes so as to read and parse those documents.


  • Extend an application that I have created, which will parse U.S. treasury bond XML data.

RESOURCES


You might want to reference the following Android developer pages:

  • The following contains the reference to the Node class: http://developer.android.com/reference/org/w3c/dom/Node.html


  • The following contains the reference to the NodeList class: http://developer.android.com/reference/org/w3c/dom/NodeList.html


  • The following contains the reference to the org.w3c.dom Document object: http://developer.android.com/reference/org/w3c/dom/Document.html

The following links are to the XML documents that you will use in the lab.

  • The following contains the NOAA page that we are using: http://forecast.weather.gov/MapClick.php?lat=39.3233&lon=-120.379&unit=0&lg=english&FcstType=dwml


  • The following contains the U.S. Treasury page: http://data.treasury.gov/feed.svc/DailyTreasuryLongTermRateData?$filter=month(QUOTE_DATE)%20eq%204%20and%20year(QUOTE_DATE)%20eq%202015


HANDS-0N ACTIVITY: Add XML Code to an Existing Activity


In this first part of the lab, you will extend the application that I have created (NetworkDemo1). Please download a current copy. I have modified it since the initial upload. The .zip file appears on the Lecture notes page for the class:

This version of the application contains a Java file named ParseXMLActivity.java. It already contains the code to create the background thread, download the XML and parse it.

In this activity, you will extend the code to display additional information from the NOAA document.


  1. Open the file named ParseXMLActivity.java. Scroll to the end of the file. Note that the following code already exists to get the text for the Description element. There is only one element with the tag named so nlDescription.item(0) contains the node from the list. The getFirstChild() method of the Node object returns the text node. The getNodeValue() method gets the actual text.



  2. The following image shows the a segment of the XML document with which you will work next:




  3. After the code for the Description element, enter the following statements that will get the current forecast.




The following list describes the above code.

  • The XML document is configured such that, there is one element named . It has an immediate child named , and then multiple elements that contain the worded forecast for each consecutive day.

  • Note that I have played used item(3) to get the proper node. There is an extra text node that contains no data if you examine the parsed document.

Now, try this on your own.

  1. Write the code to get the next forecast (tommorrow’s forecast). I have already created a TextView in the activity named tvForecastTommorow.




  2. Now, see if you can get the daily maximum and minimum temperature for the first daily forecast:


HANDS-0N ACTIVITY: Creating a new activity and background task.


In this part of the lab, you will create another activity that will display quotes from the US treasury department. This lab corresponds to your final assignment. I have provided the XML for in the lab. You will be processing the following URL:

http://data.treasury.gov/feed.svc/DailyTreasuryLongTermRateData?$filter=month(QUOTE_DATE)%20eq%204%20and%20year(QUOTE_DATE)%20eq%202015



  1. Create a new activity named ParseTreasuryXMLActivity.java.


  2. On the main activity (ActivityMain.xml), create a button that will display the new activity. As shown in the other buttons, pass the above URL to this new activity.


  3. Now, create the code template for this new activity. The code what you write should mimic the code appearing on the page ParseXMLActivity.java. That is, you will need to create the following


  • Override the onCreate method. Use the Connectivity manager to test that the network is available. If it is, execute the background worker process that you will create in a moment.


  • Create a class that mimics the DownloadXMLAndParse method from the ParseXMLActivity.java file.

    • Create the background worker (doInBackground) and other procedures and procedures using the ParseXMLActivity.java file as an example.


    • Implement the onPostExecute method which will retrieve information from the XML document and display it into corresponding form widgets.


    • You should be able to copy the downloadURL and readIt methods verbatim from the ParseXML Activity.java file.


  • Read the following data points from the XML file and display them.


    • Find the local name of the elements named properties. Using the first element, display the elements named QUOTE_DATE, RATE_TYPE, and RATE members.


    • Now extend the program. There are several elements named properties. Each contains a quote for a specific date. Get the number of
      elements. The number will be between 1 and the total number of elements. Also the user to select / enter this value. Based on the value selected, display the corresponding quotation values.

Directory: faculty -> ekedahl -> IS389
faculty -> Curriculum vitae wei chen professor
faculty -> Digital image warping
faculty -> Samples of Elements Exam Question III contains All Prior Exam Qs III except
faculty -> 【Education&Working Experience】
faculty -> References Abe, M., A. Kitoh and T. Yasunari, 2003: An evolution of the Asian summer monsoon associated with mountain uplift —Simulation with the mri atmosphere-ocean coupled gcm. J. Meteor. Soc. Japan, 81
faculty -> Ralph R. Ferraro Chief, Satellite Climate Studies Branch, noaa/nesdis
faculty -> Unit IV text: Types of Oil, Types of Prices Grammar: that/those of, with revision
IS389 -> Installing java, eclipse, and android sdks to setup an android development environment
IS389 -> Lab creating a First Android Project
IS389 -> Is 389 android fragment lab ekedahl

Download 10.23 Kb.

Share with your friends:




The database is protected by copyright ©ininet.org 2020
send message

    Main page