Else Set result and

msg = new Message () ; I store updated msg. what = 0; H JobEntry msg.obj = (Object)("Failed to Close Job"); progresshandler.sendMessage(msg); CloseJob.this.setResult(0);

Log.d("CH12","Failed to submit job close signature: " + e.getMessage());


At this point, we have a signature on the screen and need to capture it. A new File-OutputStream O is obtained for a file on the local filesystem, and the signature is written to this file. We are now ready to transmit this file to the server—remember, we want to bill the client as soon as possible for work completed!

In preparation for sending the signature to the server, the signature file contents are read into a byte array via an instance of a FilelnputStream. Using the Prefs instance to get specific configuration information, a URL is constructed in order to POST data to the server. The query String of the URL contains the jobid and the POST data contains the image itself. A BufferedOutputStream © is employed to POST data, which consists of the captured signature in JPEG format.

Once the job data and signature have been sent to the server, the response data is read back from the server Q. A specific string indicates a successful transmission Q.

Upon successful closing, the JobEntry status member is marked as CLOSED ©, and this JobEntry is converted to a Bundle so that it may be communicated to the caller by invoking the setResult() method Q. Once the Handler receives the "I'm done" message and the Activity finishes, this data is propagated back to the ShowJob and all the way back to the ManageJob Activity.

And that thankfully wraps up the source code review for the Android side of things! There were some methods omitted from this text to limit this already very long chapter, so please be sure to examine the full source code. Now it's time to look at the server application.

0 0

Post a comment