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

BUS225: Project Management - As 1554 part 1 - Give me liberty fifth edition pdf - The thrill of the grass sparknotes - I need (1200 words) Report on Flexible spectrum usage - Triage assessment form crisis intervention - Hersey and blanchard's situational leadership model ppt - Establishing patterns and trends in the data collected - Leadership and nursing care management diane huber pdf - From bean to cup how starbucks transformed its supply chain - Pom qm version 4 download - Mixing ammonium nitrate and sodium hydroxide solutions gives - Alcatraz oliver riot lyrics genius - Gp synergy training regions - War photographer poem print out - Ethics in health services management 5th edition - I need a 470 words on copywrite project on 32 short messages template in English need to reform. - MMG 525 OL01 - Statistical Decision Techniquesfor Managers - Parenting - On january boston enterprises issues bonds - Challenger sales methodology wikipedia - Persuasive speech outline on exercise - Ucl isd service desk - Smooth fox terrier club - What do peppered moths do during winter - Prosectus Draft - Malcolm x coming to an awareness of language summary - Discussion 3A - Is the giant panda a herbivore carnivore or omnivore - Biology of Mind - Assignment 4 business start up proposal - Copper ii sulfate and ammonium hydroxide reaction - Ghost mountain riders mc - Cleanbeebaby - I can't download the video to tiktok, help me. - Apa code of ethics psychology - Write 3 paragraphs on the topics. - It takes courage poem summary - Colour symbol image template - Products such as furniture, audio equipment, bicycles, and clothing are generally classified as: - 3 responses with 60 words each (No plag) - Public Management of Undocumented Immigrants - The mean amount purchased by a typical customer - Life doesn t frighten me - Final Project - IoT Security Research - Monty python god in clouds - Itw patent society - Global marketing keegan and green 9th edition pearson publishing - Www biointeractive org answer key - Mills personal troubles and public issues - Advantages and disadvantages of deficit spending - Nh3 lewis dot structure - Stephen wyman patsy smith - Shop lululemon con secure orders returns jsp - 1199 chateau road pasadena ca - Discussion - BUSN 602 weel 7 forum - Q link pendant australia - Education Essay - Castle of otranto plot summary - Apple inc performance in a zero sum world economy - Lines of latitude and climate zones - Condensed structural formula for cis 4 octene - Unit VII Project - Week 7 Discussion - King lear study guide - Trauma Center Research Paper - Propose a mechanism for the following reaction - Iso 5817 pdf 2014 - Broker/generalist model of case management - E60 m5 ionic module - Concepts of database management 8th edition chapter 5 answers - Melissa owns the following portfolio of stocks. what is the return on her portfolio? - Vce english language analysis practice articles - Watch pan's labyrinth hulu - The investment in the notes receivable earns interest at a rate of 12% per year. - Wave on a string simulation worksheet answers - Conveyor belt project management - Mcdonalds training and development ppt - Psycho 6 - 4 regulative principles of iskcon - First Aid-Nursing - How much electricity does a waterbed heater use - Coles direct sourcing pvt ltd - Church music department mission statement - Hamer hall seating capacity - Module 6 Sociology - Colanialism - Assumption and constraints example - Abcdebook coupon code - Internship report sample business administration - CISB 15 - Virginia henderson 14 basic needs ppt - Change management simulation power and influence chegg - Carnival cruise lines case study - Walt disney world resort mission statement - Glencoe accounting workbook answers chapter 10 - Gateshead council planning department - Global wine wars new world challenges old - Counseling