Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need this as an Android application. Your goal for this assignment is to utilize

ID: 3835443 • Letter: N

Question

Need this as an Android application.

Your goal for this assignment is to utilize the ASyncTask class for background processing of data retrieved from a web service.

Write an android app that provides driving directions based on "start" and "end" input from the user (very similar to the user interface on google maps for getting directions). This application should include one activity (screen) that contains two text fields with labels for input of a source and destination, a button ("Get Directions) which retrieves the directions (from a web service) using the input provided and a text area which displays the resulting driving directions listed as steps.

You must connect to a google web service and make a web service call to retrieve the directions.

Here is the link to the google directions API:

https://developers.google.com/maps/documentation/directions/

You must use the ASyncTask class for background processing (connecting and making the call to the web service, and parsing the resulting output for display)

The output from the web service must be XML (specified in the web service call) and not JSON.

While the background task is processing (connecting, parsing output) the user interface should display a progress bar.

Hints

1. Here is an example web service call (notice the format specified for results is xml)

2. "http://maps.googleapis.com/maps/api/directions/xml?origin=Toronto&destination=Montreal&sensor=false"
You will need to analyze the xml output for parsing the results. It may be a good idea to copy/paste the above call into your browser and execute to see the resulting XML output.

3. The onPostExecute callback is where you will display the results of the web service call on the UI. This method can be passed an ArrayList of all steps by specifying this type in the class definition and as a parameter to onPostExecute.

4. To make web service calls in Android, the URLConnection and HttpConnection classes are very useful. There are many examples on the web.

5. To parse XML in Android, you will need to use the XmlPullParser and XMLPullParserFactory classes. Pay attention to xml tags "DirectionsResponse", "step", and "html_instructions". The next(), nextText(), getName(), and getEventType methods are very useful for parsing, as well as the END_TAG and START_TAG enums

6. To remove html from a String object, use the following method (android.text.Html.fromHtml(myString).toString())

To test the progress bar implementation, you may want to use Thread.sleep(mlliseconds) in your background processing to simulate network congestion / slow connection. (Basically, to see your progress bar display, otherwise, the network connection and processing may be so fast that you never see the progress bar).

Explanation / Answer

HRESULT CImpIPersistStream::Load(IStream *pstm)
{
IMoniker *pmkPath;
IStream *pstmAsync;
IBindCtx *pbc;
/*
* Load properties with pstm->Read, which is either blocking
* or synchronous.
* Assume that one property is a way moniker, which is
* re-made with OleLoadFromStream into pmkPath.
*
* Also, expect that m_pbsc is the IBindStatusCallback
* usage, and m_pEnumFE is the FORMATETC enumerator.
*/
/pIBindHost is a pointer to the holder's IBindHost.
CreateAsyncBindCtx(0, NULL, m_pEnumFE, &pbc);
pIBindHost->MonikerBindToStorage(pmkPath, pbc, m_pbsc,
IID_IStream, &pstmAsync);
/Do this lone for async monikers.
on the off chance that (NULL!=pstm)
pstmAsync->Release();
pbc->Release();
pmkPath->Release();
/Data appears in IBindStatusCallback::OnDataAvailable.
return S_OK;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote