Performing Network Operations

Dependencies and prerequisites

  • Android 1.6 (API level 4) or higher
  • A device that is able to connect to mobile and Wi-Fi networks

You should also read

Try it out

Download the sample

NetworkUsage.zip

This class explains the basic tasks involved in connecting to the network, monitoring the network connection (including connection changes), and giving users control over an app's network usage. It also describes how to parse and consume XML data.

This class includes a sample application that illustrates how to perform common network operations. You can download the sample (to the right) and use it as a source of reusable code for your own application.

By going through these lessons, you'll have the fundamental building blocks for creating Android applications that download content and parse data efficiently, while minimizing network traffic.

Lessons

Connecting to the Network
Learn how to connect to the network, choose an HTTP client, and perform network operations outside of the UI thread.
Managing Network Usage
Learn how to check a device's network connection, create a preferences UI for controlling network usage, and respond to connection changes.
Parsing XML Data
Learn how to parse and consume XML data.