Week 8 Lecture/Tutorial - COIT20270
Objectives
Connect to the web using HTTP
Use XML web services
Use Jason web services
Connect to a socket server
Connect to the web using HTTP
Read the introduction to Networking on pages 393-394 and complete the Try It Out on pages
394-395 using Networking and read the How It Works on pages 395-396 of the textbook.
Read the Downloading Binary Data section on page 396 and make the modifications to the
Networking project as discussed on pages 396-398. Read the How It Works on pages 398-401 of
the textbook and make the suggested changes to the Networking project. Read the Downloading
Text Data section on page 402 and make the modifications to the Networking project as discussed
on pages 402-403. Read the How It Works on page 403 of the textbook.
Use XML web services
Read the Accessing Wb Services Using the GET Method section on page 404 of the text and then
using Networking as the starting point complete the Try It Out on pages 405-407 and then read the
How It Works on pages 407-409.
Use JASON web services
Read the introduction on pages 409-411 and then using the JASON project as the starting point
complete the Try It Out on pages 411-413 and then read the How It Works on pages 414-416.
Connect to a socket server
Read the introduction on pages 417 and then using the Sockets project as the starting point complete
the Try It Out on pages 417-422 and then read the How It Works on pages 423-426.
Questions
Complete exercise 1 to 3 on page 426 of the text by Lee.
COIT20270 App Development for Mobile Platforms https://moodle.cqu.edu.au/pluginfile.php/582739/mod_resource/conten...
1 of 2 26/5/17, 5:15 pmComplete portfolio entry in Mahara for this week.
Assignment 2 - guide
In your onOptionsItemSelected() method in your MainActivity.java file you currently handle
the Send all entries menu choice. Start there by adding an AlertDialog, similar to that on
pages 44-45 of the textbook but with modified setPositiveButton() and setNegativeButton()
methods.
1.
The setPositiveButton() function is where you clear the apps database, open a ProgressDialog
(see pages 51-52 of the text for an example), send the email message and then clear all the
app's log entries. To clear the database you will need a context object to pass into the new
DBAdapter() call. In the case statement just befor you write your new AlertDialog.Builder()
code, add the line final Context ctx = this; and use the ctx variable in your call to
DBAdapter().
2.
Most of the rest of what you do in the setPositiveButton() function is straight forward, but you
need some way of getting all your data into a single string to use as the message for the email
(see pages 345-347 of the textbook). Create a new string object and concatenate the username
from the profile to the string object. Then use a for loop to loop through your log entries,
concatenating the data (vehicle type, driver name, registration number, start time, first break,
second break, and end time) to the string. At the end of the for loop use the sendEmail()
function from page 345 of the textbook to send the email.
3.
Do not forget to call .create().show() on your AlertDialog object or it will not appear when it
should. Also remember to create a gmail email account and to set up your app for email as
given in last weeks lecture/tutorial notes.
4.
Create a Word .docx file for the second assignment and paste a copy of the received email into
this file.
5.
© Copyright 2016, R. Balsys, CQU.
COIT20270 App Development for Mobile Platforms https://moodle.cqu.edu.au/pluginfile.php/582739/mod_resource/conten...
2 of 2 26/5/17, 5:15 pm