diff --git a/docs/html/guide/topics/connectivity/index.jd b/docs/html/guide/topics/connectivity/index.jd index 385cf08b4a3c3..9025d4d1c2489 100644 --- a/docs/html/guide/topics/connectivity/index.jd +++ b/docs/html/guide/topics/connectivity/index.jd @@ -7,21 +7,9 @@ page.landing.image=images/develop/connectivity.png
-
-

Blog Articles

- - -

Android’s HTTP Clients

-

Most network-connected Android apps will use HTTP to send and receive data. Android -includes two HTTP clients: HttpURLConnection and Apache HTTP Client. Both support HTTPS, streaming -uploads and downloads, configurable timeouts, IPv6 and connection pooling.

-
- -
- -
+

Training

- +

Transferring Data Without Draining the Battery

This class demonstrates the best practices for scheduling and executing downloads using @@ -29,14 +17,14 @@ techniques such as caching, polling, and prefetching. You will learn how the pow the wireless radio can affect your choices on when, what, and how to transfer data in order to minimize impact on battery life.

- +

Syncing to the Cloud

This class covers different strategies for cloud enabled applications. It covers syncing data with the cloud using your own back-end web application, and backing up data using the cloud so that users can restore their data when installing your application on a new device.

- +
-
\ No newline at end of file +
diff --git a/docs/html/training/articles/security-ssl.jd b/docs/html/training/articles/security-ssl.jd index 7f43d9cd48eab..c3a2d9ebf0118 100644 --- a/docs/html/training/articles/security-ssl.jd +++ b/docs/html/training/articles/security-ssl.jd @@ -376,9 +376,8 @@ support Server Nam hostname to the server so the proper certificate can be returned.

Fortunately, {@link javax.net.ssl.HttpsURLConnection} supports -SNI since Android 2.3. Unfortunately, Apache -HTTP Client does not, which is one of the many reasons we discourage its use. One workaround -if you need to support Android 2.2 (and older) or Apache HTTP Client is to set up an alternative +SNI since Android 2.3. One workaround +if you need to support Android 2.2 (and older) is to set up an alternative virtual host on a unique port so that it's unambiguous which server certificate to return.

The more drastic alternative is to replace {@link javax.net.ssl.HostnameVerifier} diff --git a/docs/html/training/basics/network-ops/connecting.jd b/docs/html/training/basics/network-ops/connecting.jd index 060148064a92b..798a9ee718d71 100644 --- a/docs/html/training/basics/network-ops/connecting.jd +++ b/docs/html/training/basics/network-ops/connecting.jd @@ -49,14 +49,10 @@ application manifest must include the following permissions:

Choose an HTTP Client

-

Most network-connected Android apps use HTTP to send and receive data. -Android includes two HTTP clients: {@link java.net.HttpURLConnection} and the Apache HTTP client. -Both support HTTPS, streaming uploads and downloads, configurable -timeouts, IPv6, and connection pooling. We recommend using {@link -java.net.HttpURLConnection} for applications targeted at Gingerbread and higher. For -more discussion of this topic, see the blog post Android's HTTP Clients.

+

Most network-connected Android apps use HTTP to send and receive data. The +Android platform includes the {@link java.net.HttpURLConnection} client, which +supports HTTPS, streaming uploads and downloads, configurable timeouts, +IPv6, and connection pooling.

Check the Network Connection

diff --git a/docs/html/training/volley/requestqueue.jd b/docs/html/training/volley/requestqueue.jd index 6d19cee704e93..43b1e3f71f774 100644 --- a/docs/html/training/volley/requestqueue.jd +++ b/docs/html/training/volley/requestqueue.jd @@ -39,36 +39,11 @@ as a singleton, which makes the {@code RequestQueue} last the lifetime of your a of the requests, and a cache to handle caching. There are standard implementations of these available in the Volley toolbox: {@code DiskBasedCache} provides a one-file-per-response cache with an in-memory index, and {@code BasicNetwork} provides a network transport based -on your choice of the Apache HTTP client {@code android.net.http.AndroidHttpClient} or -{@link java.net.HttpURLConnection}.

+on your preferred HTTP client.

{@code BasicNetwork} is Volley's default network implementation. A {@code BasicNetwork} must be initialized with the HTTP client your app is using to connect to the network. -Typically this is a {@link java.net.HttpURLConnection}:

- -

To create an app that runs on all versions of Android, you can check the version of -Android the device is running and choose the appropriate HTTP client, for example:

- -
-HttpStack stack;
-...
-// If the device is running a version >= Gingerbread...
-if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
-    // ...use HttpURLConnection for stack.
-} else {
-    // ...use AndroidHttpClient for stack.
-}
-Network network = new BasicNetwork(stack);
-
+Typically this is an {@link java.net.HttpURLConnection}.

This snippet shows you the steps involved in setting up a {@code RequestQueue}:

@@ -88,7 +63,7 @@ mRequestQueue = new RequestQueue(cache, network); // Start the queue mRequestQueue.start(); -String url ="http://www.myurl.com"; +String url ="http://www.example.com"; // Formulate the request and handle the response. StringRequest stringRequest = new StringRequest(Request.Method.GET, url, @@ -107,7 +82,8 @@ StringRequest stringRequest = new StringRequest(Request.Method.GET, url, // Add the request to the RequestQueue. mRequestQueue.add(stringRequest); -... + +// ...

If you just need to make a one-time request and don't want to leave the thread pool @@ -198,7 +174,8 @@ class:

// Get a RequestQueue RequestQueue queue = MySingleton.getInstance(this.getApplicationContext()). getRequestQueue(); -... + +// ... // Add a request (in this example, called stringRequest) to your RequestQueue. MySingleton.getInstance(this).addToRequestQueue(stringRequest);