Loading...

Messages

Proposals

Stuck in your homework and missing deadline? Get urgent help in $10/Page with 24 hours deadline

Get Urgent Writing Help In Your Essays, Assignments, Homeworks, Dissertation, Thesis Or Coursework & Achieve A+ Grades.

Privacy Guaranteed - 100% Plagiarism Free Writing - Free Turnitin Report - Professional And Experienced Writers - 24/7 Online Support

Downloadimagetask android

27/03/2021 Client: saad24vbs Deadline: 2 Day

COIT20270 Application Development for Mobile Platforms Week 8: Networking

Dr. R. Balsys, CQU, 2018.

Source: Beginning Android Programming with Android Studio, J.F. DiMarzio, 2016

Week 8 – Networking

This week we:

Connect to the web using HTTP

Use XML web services

Use Jason web services

2

CQU - COIT20270 Application Development for Mobile Platforms

Using the HTTP web services

HTTP is used as the main protocol in the WWW

It is used in tasks such as downloading web pages, and binary data such as images, sound and video

To use the HTTP protocol your app must set the uses INTERNET permission in your Android manifest file

You use the OpenHttpConnection() method that takes an URL string as parameter to open a connection to the specified URL

By opening an InputStream object you can download bytes from the URL

3

CQU - COIT20270 Application Development for Mobile Platforms

…Using the HTTP web services

You must set the connection method using setRequestMethod(). Usually you use the HTTP GET verb for this

When the connection is established a HTTP response code is returned. If this is HTTP_OK then you can proceed to get the data using getInputStream()

4

CQU - COIT20270 Application Development for Mobile Platforms

Downloading Binary Data

To download an image from a web server you use the synchronous DownloadImage() method. This returns a Bitmap object. It does this by opening a HTTP connection to the URL and uses the decodeStream() method of the BitmapFactory class to decode the InputStream instance and return it as a Bitmap

Since Android 3.0 all synchronous tasks must be wrapped in the AsyncTask class to prevent them from stalling the UI

You create a DownloadImageTask that extends AsyncTask

5

CQU - COIT20270 Application Development for Mobile Platforms

…Downloading Binary Data

In the DownloadImageTask class you define the methods doInBackground() and onPostExecute()

In doInBackground() you call DownloadImage() to get the bitmap

In onPostExecute() you display the image in your UI using a UI element

You call your DownloadImageTask class by creating an instance of it in onCreate() and then calling execute() on the instance, passing a URL as the parameter

6

CQU - COIT20270 Application Development for Mobile Platforms

…Downloading Binary Data

To read multiple images you modify the doInBackground() method to use a for loop to loop through each of the URLs. As each image is completed you call publishProgress() to give feedback

An extra onProgressUpdate() method is defined in the DownloadImageTask class to display the downloaded images

In onCreate() you pass multiple URLs as the parameters of the execute() method

NOTE: On the emulator localhost refers to the emulator itself. If getting images from your PC use your PCs IP address instead of localhost or the files will not be found

7

CQU - COIT20270 Application Development for Mobile Platforms

Downloading Text

In some circumstances you may wish to GET plain text files. The text file is stored as a String on the device

To achieve this write a DownLoadText(URL) method that returns the text file as a single String

You open a Http connection to an InputStream object. Then use an InputStreamReader instance to a new InputStreamReader() instantiated with your InputStream object

You read the incoming stream of bytes into character buffers and append the incoming String copy of the buffer contents to the final returned String

You create a subclass of AsyncTask to call DownLoadText(URL) asynchronously as before

8

CQU - COIT20270 Application Development for Mobile Platforms

Accessing Web Services using GET

Many Web services respond to a GET query with an XML file

We need to be able to connect to the web service and then parse the contents of the XML file

For example consider a web service that returns the dictionary definition of the word (eg http://services.aonware.com/DictService / DictService.asmx?op=word )

Here you need to establish the connection to the web service and then parse the XML returned

9

CQU - COIT20270 Application Development for Mobile Platforms

…Accessing Web Services using GET

Here we create a WordDefinition(String) method that returns the XML file in a local String object. We wrap this in a subclass of AsyncTask and call WordDefinition (String) asynchronously

Use OpenHttpConnection() and pass the request string as the URL, remembering to use the required word at the end of the string

You create a local instance of a Document object and use the newInstance() method of the DocumentBuilderFactory class to create a DocumentBuilderFactory instance

10

Homework is Completed By:

Writer Writer Name Amount Client Comments & Rating
Instant Homework Helper

ONLINE

Instant Homework Helper

$36

She helped me in last minute in a very reasonable price. She is a lifesaver, I got A+ grade in my homework, I will surely hire her again for my next assignments, Thumbs Up!

Order & Get This Solution Within 3 Hours in $25/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 3 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 6 Hours in $20/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 6 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 12 Hours in $15/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 12 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

6 writers have sent their proposals to do this homework:

Buy Coursework Help
Solutions Store
Exam Attempter
Top Grade Essay
Maths Master
Top Class Engineers
Writer Writer Name Offer Chat
Buy Coursework Help

ONLINE

Buy Coursework Help

Hello, I an ranked top 10 freelancers in academic and contents writing. I can write and updated your personal statement with great quality and free of plagiarism

$66 Chat With Writer
Solutions Store

ONLINE

Solutions Store

I am known as Unrivaled Quality, Written to Standard, providing Plagiarism-free woork, and Always on Time

$49 Chat With Writer
Exam Attempter

ONLINE

Exam Attempter

I have read and understood all your initial requirements, and I am very professional in this task.

$31 Chat With Writer
Top Grade Essay

ONLINE

Top Grade Essay

I am known as Unrivaled Quality, Written to Standard, providing Plagiarism-free woork, and Always on Time

$70 Chat With Writer
Maths Master

ONLINE

Maths Master

I am known as Unrivaled Quality, Written to Standard, providing Plagiarism-free woork, and Always on Time

$72 Chat With Writer
Top Class Engineers

ONLINE

Top Class Engineers

You can award me any time as I am ready to start your project curiously. Waiting for your positive response. Thank you!

$55 Chat With Writer

Let our expert academic writers to help you in achieving a+ grades in your homework, assignment, quiz or exam.

Similar Homework Questions

Dark jester on a swing assembly instructions - How to cite fasb codification - Four Case Studies on Corporate Social Responsibility - Biomedical engineering ethics examples - Journal of perinatal and neonatal nursing author guidelines - Japanese art red stamp - Pipe makers canning vale - One – Group Assessment - Caterpillar accounting fraud - Assignment: Research: Mastering Data Visualizations - 40 short stories a portable anthology 4th edition pdf free - Sink or swim case study - Spartan society to the battle of leuctra - 9 harrison court magill - Research - Mgb gt for sale ontario - Company closing letter to clients - Organization Analysis on conflict that is experienced in an organizational setting. - Escience labs biology answer key - St andrews tennis club - The execution of wanda jean movie - Title 1 lesson plan template - Gifted hands chapter summary - Cidr address overlaps with existing subnet cidr: 10.0.0.0/24. - Mean median mode range and standard deviation worksheet answers - The conscious lovers summary - I need 1000 words in ( USA Car Hire Zone) - Discussion question in-cite text - Discussion Board 1: Directional/Stabilizing/Disruptive Selection - Sheffield & district junior league - Protective security coordination centre - Short Essay For The 2 Selected Paragraph (1 Page) REALLY NEED THIS WITHIN AN HOUR OR TWO - Apple compensation plan - Verbs to write learning objectives - There is ability in disability discuss - Event driven programming paradigm - The lady doth protest too much psychology - What is one common characteristic of legends - Standard deviation rule of thumb - Which of the following activities is a reverse-flow channel of marketing? - Cardboard castle school project - Bamboo consulting is a consulting firm owned - Passage - Dr allen pain management - Heathcliff as a byronic hero - An operating lamp draws a current of 0.50 - Oasis academy lords hill - Electric arc welding setup - Temple of the public lares pompeii - Discussion: Federalism and National Homeland Security - Health Care Delivery 4.2 - 25 callana avenue rostrevor - The devil wears prada discussion questions - Learning is defined as - Which of the following is not something john claimed about love in 1 john? - 1 to the power of 10 - He li be bcnof ne - His 200 snhu - R001 01 understanding computer systems - Caroubel passamezzo from terpsichore - Write and Read your Manifestos - Chapel allerton rheumatology consultants - YouTube - Write a seven-page minimum research paper with a separate cover sheet - 1 2 3 let's go sound effect - Rocket sled physics classroom worksheet answers - Example of a ballad - Martin brundle mercedes 190e cosworth - Brock" Voluntary Active euthanasia&quot - Write a response to Derek post: - Malware domain list txt - Research Design and Sampling - Poehling medical center has a single operating room - Johns hopkins nursing evidence based practice model and guidelines pdf - Functional areas of business - Inner london boroughs map - What is informational text - Bridge to terabithia lesson plans - Total cost of merchandise purchased - Igcse japanese first language past papers - Case study - Newtown school dispute negotiation plan - Series fed class a power amplifier - Super simple songs numbers to 20 - Goldsmiths extenuating circumstances form - Race in america matthew desmond and mustafa emirbayer - EBP - Multicountry competition exists when - Deposit and withdrawal files java program - Indiana iu plagiarism test answers - 2 - Business - Business and its environment 6th edition - Pin oak soil ph - Aligned learning activities and differentiation elm 210 - Yvette's brave battle answer key - Health communication - What caused claire's miscarriage - Assessment 5 Instructions: Professional ePortfolio and Resume - Leading edge fall protection definition