Skip to content

Instantly share code, notes, and snippets.

Created May 21, 2013 01:14
Star You must be signed in to star a gist
Save JakeWharton/5616899 to your computer and use it in GitHub Desktop.
A `HttpStack` implementation for Volley that uses OkHttp as its transport.
import com.squareup.okhttp.OkHttpClient;
* An {@link HttpStack} implementation which
* uses OkHttp as its transport.
public class OkHttpStack extends HurlStack {
private final OkHttpClient client;
public OkHttpStack() {
this(new OkHttpClient());
public OkHttpStack(OkHttpClient client) {
if (client == null) {
throw new NullPointerException("Client must not be null.");
this.client = client;
@Override protected HttpURLConnection createConnection(URL url) throws IOException {
Copy link

khat33b commented May 24, 2018

What is the advantage of using OkHttp as transport for Volley?

Copy link

swankjesse commented Mar 2, 2019

OkUrlFactory is gone

It was deprecated in December 2015 and deleted in March 2019. You should use this instead:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment