Using Android network communication technology to transfer objects directly on the network

Source: Internet
Author: User
Tags json

To make a good Android application, it is essential to use the network communication technology, it is difficult to imagine a software without network interaction can eventually develop much success. So let's take a look at how web interactions are implemented in general Android apps, and here's an example of a Boook object:

As shown above, first on the phone to generate a book object, which contains the title, author, price and other data. To send this data to the server side, we take the data out of the book object and assemble it into an XML-formatted string. Then through the network API, the assembled XML string is sent to the server side. The server receives the XML string sent from the client, and the XML is parsed. The parsed data is then reassembled into a book object, and the server can then perform a series of other operations on the object.

Of course the amount of data in the XML format is large, and now many Android apps are using JSON format to transfer data in order to save traffic. However, whether using XML or JSON, the steps described in the above diagram are always unavoidable.

Feeling that this is the way to transfer data, each time the process of encapsulating and parsing XML is the most cumbersome, can you bypass the most tedious process?

As shown in the figure above, if you can call the network API and send the book object directly to the server, the entire network interaction process becomes very simple, so let's look at how to implement it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.