How to use Stetho with Volley?
Created a volley singleton class for my requests.This is my singleton class
public class VolleySingleton {
private static VolleySingleton instance;
private RequestQueue reQueue;
private VolleySingleton(Context context) {
reQueue = Volley.newRequestQueue(context,new OkHttpStack(new OkHttpClient()));
}
public static VolleySingleton getInstance(Context context) {
if(instance == null)
instance = new VolleySingleton(context);
return instance;
}
public RequestQueue getRequestQueue() {
return reQueue;
}
public <T> void addToRequestQueue(Request<T> request) {
request.setTag("app");
request.setShouldCache(false);
request.setRetryPolicy(new DefaultRetryPolicy(10000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
getRequestQueue().add(request);
}
}
And m using OKHTTP stack with my Volley implementation.This is my OKHttp.class
public class OkHttpStack implements HttpStack {
private final OkHttpClient mClient;
public OkHttpStack(OkHttpClient client) {
this.mClient = client;
}
@Override
public HttpResponse performRequest(Request<?> request, Map<String, String> additionalHeaders)
throws IOException, AuthFailureError {
OkHttpClient client = mClient.clone();
int timeoutMs = request.getTimeoutMs();
client.setConnectTimeout(timeoutMs, TimeUnit.MILLISECONDS);
client.setReadTimeout(timeoutMs, TimeUnit.MILLISECONDS);
client.setWriteTimeout(timeoutMs, TimeUnit.MILLISECONDS);
com.squareup.okhttp.Request.Builder okHttpRequestBuilder = new com.squareup.okhttp.Request.Builder();
okHttpRequestBuilder.url(request.getUrl());
Map<String, String> headers = request.getHeaders();
for (final String name : headers.keySet()) {
okHttpRequestBuilder.addHeader(name, headers.get(name));
}
for (final String name : additionalHeaders.keySet()) {
okHttpRequestBuilder.addHeader(name, additionalHeaders.get(name));
}
setConnectionParametersForRequest(okHttpRequestBuilder, request);
com.squareup.okhttp.Request okHttpRequest = okHttpRequestBuilder.build();
Call okHttpCall = client.newCall(okHttpRequest);
Response okHttpResponse = okHttpCall.execute();
StatusLine responseStatus = new BasicStatusLine(parseProtocol(okHttpResponse.protocol()), okHttpResponse.code(), okHttpResponse.message());
BasicHttpResponse response = new BasicHttpResponse(responseStatus);
response.setEntity(entityFromOkHttpResponse(okHttpResponse));
Headers responseHeaders = okHttpResponse.headers();
for (int i = 0, len = responseHeaders.size(); i < len; i++) {
final String name = responseHeaders.name(i), value = responseHeaders.value(i);
if (name != null) {
response.addHeader(new BasicHeader(name, value));
}
}
return response;
}
private static HttpEntity entityFromOkHttpResponse(Response r) throws IOException {
BasicHttpEntity entity = new BasicHttpEntity();
ResponseBody body = r.body();
entity.setContent(body.byteStream());
entity.setContentLength(body.contentLength());
entity.setContentEncoding(r.header("Content-Encoding"));
if (body.contentType() != null) {
entity.setContentType(body.contentType().type());
}
return entity;
}
@SuppressWarnings("deprecation")
private static void setConnectionParametersForRequest(com.squareup.okhttp.Request.Builder builder, Request<?> request)
throws IOException, AuthFailureError {
switch (request.getMethod()) {
case Request.Method.DEPRECATED_GET_OR_POST:
// Ensure backwards compatibility. Volley assumes a request with a null body is a GET.
byte postBody = request.getPostBody();
if (postBody != null) {
builder.post(RequestBody.create(MediaType.parse(request.getPostBodyContentType()), postBody));
}
break;
case Request.Method.GET:
builder.get();
break;
case Request.Method.DELETE:
builder.delete();
break;
case Request.Method.POST:
builder.post(createRequestBody(request));
break;
case Request.Method.PUT:
builder.put(createRequestBody(request));
break;
case Request.Method.HEAD:
builder.head();
break;
case Request.Method.OPTIONS:
builder.method("OPTIONS", null);
break;
case Request.Method.TRACE:
builder.method("TRACE", null);
break;
case Request.Method.PATCH:
builder.patch(createRequestBody(request));
break;
default:
throw new IllegalStateException("Unknown method type.");
}
}
private static ProtocolVersion parseProtocol(final Protocol p) {
switch (p) {
case HTTP_1_0:
return new ProtocolVersion("HTTP", 1, 0);
case HTTP_1_1:
return new ProtocolVersion("HTTP", 1, 1);
case SPDY_3:
return new ProtocolVersion("SPDY", 3, 1);
case HTTP_2:
return new ProtocolVersion("HTTP", 2, 0);
}
throw new IllegalAccessError("Unkwown protocol");
}
private static RequestBody createRequestBody(Request r) throws AuthFailureError {
final byte body = r.getBody();
if (body == null) return null;
return RequestBody.create(MediaType.parse(r.getBodyContentType()), body);
}
}
I also intilized my Stetho in my application.class
Stetho.initialize(
Stetho.newInitializerBuilder(this)
.enableDumpapp(
Stetho.defaultDumperPluginsProvider(this))
.enableWebKitInspector(
Stetho.defaultInspectorModulesProvider(this))
.build());
The issue is when i debug i can't get the network calls made by my application in my browser.Not sure where i am going wrong!Help!

add a comment |
Created a volley singleton class for my requests.This is my singleton class
public class VolleySingleton {
private static VolleySingleton instance;
private RequestQueue reQueue;
private VolleySingleton(Context context) {
reQueue = Volley.newRequestQueue(context,new OkHttpStack(new OkHttpClient()));
}
public static VolleySingleton getInstance(Context context) {
if(instance == null)
instance = new VolleySingleton(context);
return instance;
}
public RequestQueue getRequestQueue() {
return reQueue;
}
public <T> void addToRequestQueue(Request<T> request) {
request.setTag("app");
request.setShouldCache(false);
request.setRetryPolicy(new DefaultRetryPolicy(10000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
getRequestQueue().add(request);
}
}
And m using OKHTTP stack with my Volley implementation.This is my OKHttp.class
public class OkHttpStack implements HttpStack {
private final OkHttpClient mClient;
public OkHttpStack(OkHttpClient client) {
this.mClient = client;
}
@Override
public HttpResponse performRequest(Request<?> request, Map<String, String> additionalHeaders)
throws IOException, AuthFailureError {
OkHttpClient client = mClient.clone();
int timeoutMs = request.getTimeoutMs();
client.setConnectTimeout(timeoutMs, TimeUnit.MILLISECONDS);
client.setReadTimeout(timeoutMs, TimeUnit.MILLISECONDS);
client.setWriteTimeout(timeoutMs, TimeUnit.MILLISECONDS);
com.squareup.okhttp.Request.Builder okHttpRequestBuilder = new com.squareup.okhttp.Request.Builder();
okHttpRequestBuilder.url(request.getUrl());
Map<String, String> headers = request.getHeaders();
for (final String name : headers.keySet()) {
okHttpRequestBuilder.addHeader(name, headers.get(name));
}
for (final String name : additionalHeaders.keySet()) {
okHttpRequestBuilder.addHeader(name, additionalHeaders.get(name));
}
setConnectionParametersForRequest(okHttpRequestBuilder, request);
com.squareup.okhttp.Request okHttpRequest = okHttpRequestBuilder.build();
Call okHttpCall = client.newCall(okHttpRequest);
Response okHttpResponse = okHttpCall.execute();
StatusLine responseStatus = new BasicStatusLine(parseProtocol(okHttpResponse.protocol()), okHttpResponse.code(), okHttpResponse.message());
BasicHttpResponse response = new BasicHttpResponse(responseStatus);
response.setEntity(entityFromOkHttpResponse(okHttpResponse));
Headers responseHeaders = okHttpResponse.headers();
for (int i = 0, len = responseHeaders.size(); i < len; i++) {
final String name = responseHeaders.name(i), value = responseHeaders.value(i);
if (name != null) {
response.addHeader(new BasicHeader(name, value));
}
}
return response;
}
private static HttpEntity entityFromOkHttpResponse(Response r) throws IOException {
BasicHttpEntity entity = new BasicHttpEntity();
ResponseBody body = r.body();
entity.setContent(body.byteStream());
entity.setContentLength(body.contentLength());
entity.setContentEncoding(r.header("Content-Encoding"));
if (body.contentType() != null) {
entity.setContentType(body.contentType().type());
}
return entity;
}
@SuppressWarnings("deprecation")
private static void setConnectionParametersForRequest(com.squareup.okhttp.Request.Builder builder, Request<?> request)
throws IOException, AuthFailureError {
switch (request.getMethod()) {
case Request.Method.DEPRECATED_GET_OR_POST:
// Ensure backwards compatibility. Volley assumes a request with a null body is a GET.
byte postBody = request.getPostBody();
if (postBody != null) {
builder.post(RequestBody.create(MediaType.parse(request.getPostBodyContentType()), postBody));
}
break;
case Request.Method.GET:
builder.get();
break;
case Request.Method.DELETE:
builder.delete();
break;
case Request.Method.POST:
builder.post(createRequestBody(request));
break;
case Request.Method.PUT:
builder.put(createRequestBody(request));
break;
case Request.Method.HEAD:
builder.head();
break;
case Request.Method.OPTIONS:
builder.method("OPTIONS", null);
break;
case Request.Method.TRACE:
builder.method("TRACE", null);
break;
case Request.Method.PATCH:
builder.patch(createRequestBody(request));
break;
default:
throw new IllegalStateException("Unknown method type.");
}
}
private static ProtocolVersion parseProtocol(final Protocol p) {
switch (p) {
case HTTP_1_0:
return new ProtocolVersion("HTTP", 1, 0);
case HTTP_1_1:
return new ProtocolVersion("HTTP", 1, 1);
case SPDY_3:
return new ProtocolVersion("SPDY", 3, 1);
case HTTP_2:
return new ProtocolVersion("HTTP", 2, 0);
}
throw new IllegalAccessError("Unkwown protocol");
}
private static RequestBody createRequestBody(Request r) throws AuthFailureError {
final byte body = r.getBody();
if (body == null) return null;
return RequestBody.create(MediaType.parse(r.getBodyContentType()), body);
}
}
I also intilized my Stetho in my application.class
Stetho.initialize(
Stetho.newInitializerBuilder(this)
.enableDumpapp(
Stetho.defaultDumperPluginsProvider(this))
.enableWebKitInspector(
Stetho.defaultInspectorModulesProvider(this))
.build());
The issue is when i debug i can't get the network calls made by my application in my browser.Not sure where i am going wrong!Help!

add a comment |
Created a volley singleton class for my requests.This is my singleton class
public class VolleySingleton {
private static VolleySingleton instance;
private RequestQueue reQueue;
private VolleySingleton(Context context) {
reQueue = Volley.newRequestQueue(context,new OkHttpStack(new OkHttpClient()));
}
public static VolleySingleton getInstance(Context context) {
if(instance == null)
instance = new VolleySingleton(context);
return instance;
}
public RequestQueue getRequestQueue() {
return reQueue;
}
public <T> void addToRequestQueue(Request<T> request) {
request.setTag("app");
request.setShouldCache(false);
request.setRetryPolicy(new DefaultRetryPolicy(10000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
getRequestQueue().add(request);
}
}
And m using OKHTTP stack with my Volley implementation.This is my OKHttp.class
public class OkHttpStack implements HttpStack {
private final OkHttpClient mClient;
public OkHttpStack(OkHttpClient client) {
this.mClient = client;
}
@Override
public HttpResponse performRequest(Request<?> request, Map<String, String> additionalHeaders)
throws IOException, AuthFailureError {
OkHttpClient client = mClient.clone();
int timeoutMs = request.getTimeoutMs();
client.setConnectTimeout(timeoutMs, TimeUnit.MILLISECONDS);
client.setReadTimeout(timeoutMs, TimeUnit.MILLISECONDS);
client.setWriteTimeout(timeoutMs, TimeUnit.MILLISECONDS);
com.squareup.okhttp.Request.Builder okHttpRequestBuilder = new com.squareup.okhttp.Request.Builder();
okHttpRequestBuilder.url(request.getUrl());
Map<String, String> headers = request.getHeaders();
for (final String name : headers.keySet()) {
okHttpRequestBuilder.addHeader(name, headers.get(name));
}
for (final String name : additionalHeaders.keySet()) {
okHttpRequestBuilder.addHeader(name, additionalHeaders.get(name));
}
setConnectionParametersForRequest(okHttpRequestBuilder, request);
com.squareup.okhttp.Request okHttpRequest = okHttpRequestBuilder.build();
Call okHttpCall = client.newCall(okHttpRequest);
Response okHttpResponse = okHttpCall.execute();
StatusLine responseStatus = new BasicStatusLine(parseProtocol(okHttpResponse.protocol()), okHttpResponse.code(), okHttpResponse.message());
BasicHttpResponse response = new BasicHttpResponse(responseStatus);
response.setEntity(entityFromOkHttpResponse(okHttpResponse));
Headers responseHeaders = okHttpResponse.headers();
for (int i = 0, len = responseHeaders.size(); i < len; i++) {
final String name = responseHeaders.name(i), value = responseHeaders.value(i);
if (name != null) {
response.addHeader(new BasicHeader(name, value));
}
}
return response;
}
private static HttpEntity entityFromOkHttpResponse(Response r) throws IOException {
BasicHttpEntity entity = new BasicHttpEntity();
ResponseBody body = r.body();
entity.setContent(body.byteStream());
entity.setContentLength(body.contentLength());
entity.setContentEncoding(r.header("Content-Encoding"));
if (body.contentType() != null) {
entity.setContentType(body.contentType().type());
}
return entity;
}
@SuppressWarnings("deprecation")
private static void setConnectionParametersForRequest(com.squareup.okhttp.Request.Builder builder, Request<?> request)
throws IOException, AuthFailureError {
switch (request.getMethod()) {
case Request.Method.DEPRECATED_GET_OR_POST:
// Ensure backwards compatibility. Volley assumes a request with a null body is a GET.
byte postBody = request.getPostBody();
if (postBody != null) {
builder.post(RequestBody.create(MediaType.parse(request.getPostBodyContentType()), postBody));
}
break;
case Request.Method.GET:
builder.get();
break;
case Request.Method.DELETE:
builder.delete();
break;
case Request.Method.POST:
builder.post(createRequestBody(request));
break;
case Request.Method.PUT:
builder.put(createRequestBody(request));
break;
case Request.Method.HEAD:
builder.head();
break;
case Request.Method.OPTIONS:
builder.method("OPTIONS", null);
break;
case Request.Method.TRACE:
builder.method("TRACE", null);
break;
case Request.Method.PATCH:
builder.patch(createRequestBody(request));
break;
default:
throw new IllegalStateException("Unknown method type.");
}
}
private static ProtocolVersion parseProtocol(final Protocol p) {
switch (p) {
case HTTP_1_0:
return new ProtocolVersion("HTTP", 1, 0);
case HTTP_1_1:
return new ProtocolVersion("HTTP", 1, 1);
case SPDY_3:
return new ProtocolVersion("SPDY", 3, 1);
case HTTP_2:
return new ProtocolVersion("HTTP", 2, 0);
}
throw new IllegalAccessError("Unkwown protocol");
}
private static RequestBody createRequestBody(Request r) throws AuthFailureError {
final byte body = r.getBody();
if (body == null) return null;
return RequestBody.create(MediaType.parse(r.getBodyContentType()), body);
}
}
I also intilized my Stetho in my application.class
Stetho.initialize(
Stetho.newInitializerBuilder(this)
.enableDumpapp(
Stetho.defaultDumperPluginsProvider(this))
.enableWebKitInspector(
Stetho.defaultInspectorModulesProvider(this))
.build());
The issue is when i debug i can't get the network calls made by my application in my browser.Not sure where i am going wrong!Help!

Created a volley singleton class for my requests.This is my singleton class
public class VolleySingleton {
private static VolleySingleton instance;
private RequestQueue reQueue;
private VolleySingleton(Context context) {
reQueue = Volley.newRequestQueue(context,new OkHttpStack(new OkHttpClient()));
}
public static VolleySingleton getInstance(Context context) {
if(instance == null)
instance = new VolleySingleton(context);
return instance;
}
public RequestQueue getRequestQueue() {
return reQueue;
}
public <T> void addToRequestQueue(Request<T> request) {
request.setTag("app");
request.setShouldCache(false);
request.setRetryPolicy(new DefaultRetryPolicy(10000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
getRequestQueue().add(request);
}
}
And m using OKHTTP stack with my Volley implementation.This is my OKHttp.class
public class OkHttpStack implements HttpStack {
private final OkHttpClient mClient;
public OkHttpStack(OkHttpClient client) {
this.mClient = client;
}
@Override
public HttpResponse performRequest(Request<?> request, Map<String, String> additionalHeaders)
throws IOException, AuthFailureError {
OkHttpClient client = mClient.clone();
int timeoutMs = request.getTimeoutMs();
client.setConnectTimeout(timeoutMs, TimeUnit.MILLISECONDS);
client.setReadTimeout(timeoutMs, TimeUnit.MILLISECONDS);
client.setWriteTimeout(timeoutMs, TimeUnit.MILLISECONDS);
com.squareup.okhttp.Request.Builder okHttpRequestBuilder = new com.squareup.okhttp.Request.Builder();
okHttpRequestBuilder.url(request.getUrl());
Map<String, String> headers = request.getHeaders();
for (final String name : headers.keySet()) {
okHttpRequestBuilder.addHeader(name, headers.get(name));
}
for (final String name : additionalHeaders.keySet()) {
okHttpRequestBuilder.addHeader(name, additionalHeaders.get(name));
}
setConnectionParametersForRequest(okHttpRequestBuilder, request);
com.squareup.okhttp.Request okHttpRequest = okHttpRequestBuilder.build();
Call okHttpCall = client.newCall(okHttpRequest);
Response okHttpResponse = okHttpCall.execute();
StatusLine responseStatus = new BasicStatusLine(parseProtocol(okHttpResponse.protocol()), okHttpResponse.code(), okHttpResponse.message());
BasicHttpResponse response = new BasicHttpResponse(responseStatus);
response.setEntity(entityFromOkHttpResponse(okHttpResponse));
Headers responseHeaders = okHttpResponse.headers();
for (int i = 0, len = responseHeaders.size(); i < len; i++) {
final String name = responseHeaders.name(i), value = responseHeaders.value(i);
if (name != null) {
response.addHeader(new BasicHeader(name, value));
}
}
return response;
}
private static HttpEntity entityFromOkHttpResponse(Response r) throws IOException {
BasicHttpEntity entity = new BasicHttpEntity();
ResponseBody body = r.body();
entity.setContent(body.byteStream());
entity.setContentLength(body.contentLength());
entity.setContentEncoding(r.header("Content-Encoding"));
if (body.contentType() != null) {
entity.setContentType(body.contentType().type());
}
return entity;
}
@SuppressWarnings("deprecation")
private static void setConnectionParametersForRequest(com.squareup.okhttp.Request.Builder builder, Request<?> request)
throws IOException, AuthFailureError {
switch (request.getMethod()) {
case Request.Method.DEPRECATED_GET_OR_POST:
// Ensure backwards compatibility. Volley assumes a request with a null body is a GET.
byte postBody = request.getPostBody();
if (postBody != null) {
builder.post(RequestBody.create(MediaType.parse(request.getPostBodyContentType()), postBody));
}
break;
case Request.Method.GET:
builder.get();
break;
case Request.Method.DELETE:
builder.delete();
break;
case Request.Method.POST:
builder.post(createRequestBody(request));
break;
case Request.Method.PUT:
builder.put(createRequestBody(request));
break;
case Request.Method.HEAD:
builder.head();
break;
case Request.Method.OPTIONS:
builder.method("OPTIONS", null);
break;
case Request.Method.TRACE:
builder.method("TRACE", null);
break;
case Request.Method.PATCH:
builder.patch(createRequestBody(request));
break;
default:
throw new IllegalStateException("Unknown method type.");
}
}
private static ProtocolVersion parseProtocol(final Protocol p) {
switch (p) {
case HTTP_1_0:
return new ProtocolVersion("HTTP", 1, 0);
case HTTP_1_1:
return new ProtocolVersion("HTTP", 1, 1);
case SPDY_3:
return new ProtocolVersion("SPDY", 3, 1);
case HTTP_2:
return new ProtocolVersion("HTTP", 2, 0);
}
throw new IllegalAccessError("Unkwown protocol");
}
private static RequestBody createRequestBody(Request r) throws AuthFailureError {
final byte body = r.getBody();
if (body == null) return null;
return RequestBody.create(MediaType.parse(r.getBodyContentType()), body);
}
}
I also intilized my Stetho in my application.class
Stetho.initialize(
Stetho.newInitializerBuilder(this)
.enableDumpapp(
Stetho.defaultDumperPluginsProvider(this))
.enableWebKitInspector(
Stetho.defaultInspectorModulesProvider(this))
.build());
The issue is when i debug i can't get the network calls made by my application in my browser.Not sure where i am going wrong!Help!


edited Aug 26 '15 at 8:41
goonerDroid
asked Aug 14 '15 at 14:11


goonerDroidgoonerDroid
7,99882749
7,99882749
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
Add this file in project Updated OkHttpStack
and
Try this:
Stetho.initializeWithDefaults(this);
OkHttpClient client = new OkHttpClient();
client.networkInterceptors().add(new StethoInterceptor());
mRequestQueue = Volley.newRequestQueue(getApplicationContext(), new OkHttpStack(client));
with following dependencies:
compile 'com.facebook.stetho:stetho:1.1.1'
compile 'com.facebook.stetho:stetho-okhttp:1.1.1'
compile 'com.squareup.okhttp:okhttp:2.3.0'
Hello, I'm curious how you handle SSL with OkHTTPStack? I'm currrently using HurlStack with SSL in Volley and would like to switch to OkHTTP so I can use Stetho for network tracing.
– Woppi
Dec 20 '16 at 9:19
add a comment |
the answer of @Sabeeh is correct, only update your libraries in your gradle
compile 'com.facebook.stetho:stetho:1.3.1'
compile 'com.facebook.stetho:stetho-okhttp:1.3.1'
compile 'com.facebook.stetho:stetho-urlconnection:1.3.1'
compile 'com.squareup.okhttp:okhttp:2.3.0'
compile 'com.mcxiaoke.volley:library:1.0.19'
Now in your Application class of your project add this
Stetho.initializeWithDefaults(this);
OkHttpClient okHttpClient = new OkHttpClient();
okHttpClient.networkInterceptors().add(new StethoInterceptor());
mRequestQueue = Volley.newRequestQueue(this, new OkHttpStack(okHttpClient));
Import your libraries and yet we will see an error with OkHttpStack(okHttpClient) so you only need to copy this code provided by @bryanstern Class OkHttpStack so create the file import and enjoy it
Hello, I'm curious how you handle SSL with OkHTTPStack? I'm currrently using HurlStack with SSL in Volley and would like to switch to OkHTTP so I can use Stetho for network tracing.
– Woppi
Dec 20 '16 at 9:19
thank you , thanks a lot!
– Ninad Kambli
Jan 4 '17 at 7:29
add a comment |
If you want to use Stetho for volley without using OkHttp stack.
Please refer this link. Stetho for Volley
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f32012160%2fhow-to-use-stetho-with-volley%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Add this file in project Updated OkHttpStack
and
Try this:
Stetho.initializeWithDefaults(this);
OkHttpClient client = new OkHttpClient();
client.networkInterceptors().add(new StethoInterceptor());
mRequestQueue = Volley.newRequestQueue(getApplicationContext(), new OkHttpStack(client));
with following dependencies:
compile 'com.facebook.stetho:stetho:1.1.1'
compile 'com.facebook.stetho:stetho-okhttp:1.1.1'
compile 'com.squareup.okhttp:okhttp:2.3.0'
Hello, I'm curious how you handle SSL with OkHTTPStack? I'm currrently using HurlStack with SSL in Volley and would like to switch to OkHTTP so I can use Stetho for network tracing.
– Woppi
Dec 20 '16 at 9:19
add a comment |
Add this file in project Updated OkHttpStack
and
Try this:
Stetho.initializeWithDefaults(this);
OkHttpClient client = new OkHttpClient();
client.networkInterceptors().add(new StethoInterceptor());
mRequestQueue = Volley.newRequestQueue(getApplicationContext(), new OkHttpStack(client));
with following dependencies:
compile 'com.facebook.stetho:stetho:1.1.1'
compile 'com.facebook.stetho:stetho-okhttp:1.1.1'
compile 'com.squareup.okhttp:okhttp:2.3.0'
Hello, I'm curious how you handle SSL with OkHTTPStack? I'm currrently using HurlStack with SSL in Volley and would like to switch to OkHTTP so I can use Stetho for network tracing.
– Woppi
Dec 20 '16 at 9:19
add a comment |
Add this file in project Updated OkHttpStack
and
Try this:
Stetho.initializeWithDefaults(this);
OkHttpClient client = new OkHttpClient();
client.networkInterceptors().add(new StethoInterceptor());
mRequestQueue = Volley.newRequestQueue(getApplicationContext(), new OkHttpStack(client));
with following dependencies:
compile 'com.facebook.stetho:stetho:1.1.1'
compile 'com.facebook.stetho:stetho-okhttp:1.1.1'
compile 'com.squareup.okhttp:okhttp:2.3.0'
Add this file in project Updated OkHttpStack
and
Try this:
Stetho.initializeWithDefaults(this);
OkHttpClient client = new OkHttpClient();
client.networkInterceptors().add(new StethoInterceptor());
mRequestQueue = Volley.newRequestQueue(getApplicationContext(), new OkHttpStack(client));
with following dependencies:
compile 'com.facebook.stetho:stetho:1.1.1'
compile 'com.facebook.stetho:stetho-okhttp:1.1.1'
compile 'com.squareup.okhttp:okhttp:2.3.0'
edited Aug 18 '16 at 18:41
answered Aug 25 '15 at 17:49
SabeehSabeeh
839813
839813
Hello, I'm curious how you handle SSL with OkHTTPStack? I'm currrently using HurlStack with SSL in Volley and would like to switch to OkHTTP so I can use Stetho for network tracing.
– Woppi
Dec 20 '16 at 9:19
add a comment |
Hello, I'm curious how you handle SSL with OkHTTPStack? I'm currrently using HurlStack with SSL in Volley and would like to switch to OkHTTP so I can use Stetho for network tracing.
– Woppi
Dec 20 '16 at 9:19
Hello, I'm curious how you handle SSL with OkHTTPStack? I'm currrently using HurlStack with SSL in Volley and would like to switch to OkHTTP so I can use Stetho for network tracing.
– Woppi
Dec 20 '16 at 9:19
Hello, I'm curious how you handle SSL with OkHTTPStack? I'm currrently using HurlStack with SSL in Volley and would like to switch to OkHTTP so I can use Stetho for network tracing.
– Woppi
Dec 20 '16 at 9:19
add a comment |
the answer of @Sabeeh is correct, only update your libraries in your gradle
compile 'com.facebook.stetho:stetho:1.3.1'
compile 'com.facebook.stetho:stetho-okhttp:1.3.1'
compile 'com.facebook.stetho:stetho-urlconnection:1.3.1'
compile 'com.squareup.okhttp:okhttp:2.3.0'
compile 'com.mcxiaoke.volley:library:1.0.19'
Now in your Application class of your project add this
Stetho.initializeWithDefaults(this);
OkHttpClient okHttpClient = new OkHttpClient();
okHttpClient.networkInterceptors().add(new StethoInterceptor());
mRequestQueue = Volley.newRequestQueue(this, new OkHttpStack(okHttpClient));
Import your libraries and yet we will see an error with OkHttpStack(okHttpClient) so you only need to copy this code provided by @bryanstern Class OkHttpStack so create the file import and enjoy it
Hello, I'm curious how you handle SSL with OkHTTPStack? I'm currrently using HurlStack with SSL in Volley and would like to switch to OkHTTP so I can use Stetho for network tracing.
– Woppi
Dec 20 '16 at 9:19
thank you , thanks a lot!
– Ninad Kambli
Jan 4 '17 at 7:29
add a comment |
the answer of @Sabeeh is correct, only update your libraries in your gradle
compile 'com.facebook.stetho:stetho:1.3.1'
compile 'com.facebook.stetho:stetho-okhttp:1.3.1'
compile 'com.facebook.stetho:stetho-urlconnection:1.3.1'
compile 'com.squareup.okhttp:okhttp:2.3.0'
compile 'com.mcxiaoke.volley:library:1.0.19'
Now in your Application class of your project add this
Stetho.initializeWithDefaults(this);
OkHttpClient okHttpClient = new OkHttpClient();
okHttpClient.networkInterceptors().add(new StethoInterceptor());
mRequestQueue = Volley.newRequestQueue(this, new OkHttpStack(okHttpClient));
Import your libraries and yet we will see an error with OkHttpStack(okHttpClient) so you only need to copy this code provided by @bryanstern Class OkHttpStack so create the file import and enjoy it
Hello, I'm curious how you handle SSL with OkHTTPStack? I'm currrently using HurlStack with SSL in Volley and would like to switch to OkHTTP so I can use Stetho for network tracing.
– Woppi
Dec 20 '16 at 9:19
thank you , thanks a lot!
– Ninad Kambli
Jan 4 '17 at 7:29
add a comment |
the answer of @Sabeeh is correct, only update your libraries in your gradle
compile 'com.facebook.stetho:stetho:1.3.1'
compile 'com.facebook.stetho:stetho-okhttp:1.3.1'
compile 'com.facebook.stetho:stetho-urlconnection:1.3.1'
compile 'com.squareup.okhttp:okhttp:2.3.0'
compile 'com.mcxiaoke.volley:library:1.0.19'
Now in your Application class of your project add this
Stetho.initializeWithDefaults(this);
OkHttpClient okHttpClient = new OkHttpClient();
okHttpClient.networkInterceptors().add(new StethoInterceptor());
mRequestQueue = Volley.newRequestQueue(this, new OkHttpStack(okHttpClient));
Import your libraries and yet we will see an error with OkHttpStack(okHttpClient) so you only need to copy this code provided by @bryanstern Class OkHttpStack so create the file import and enjoy it
the answer of @Sabeeh is correct, only update your libraries in your gradle
compile 'com.facebook.stetho:stetho:1.3.1'
compile 'com.facebook.stetho:stetho-okhttp:1.3.1'
compile 'com.facebook.stetho:stetho-urlconnection:1.3.1'
compile 'com.squareup.okhttp:okhttp:2.3.0'
compile 'com.mcxiaoke.volley:library:1.0.19'
Now in your Application class of your project add this
Stetho.initializeWithDefaults(this);
OkHttpClient okHttpClient = new OkHttpClient();
okHttpClient.networkInterceptors().add(new StethoInterceptor());
mRequestQueue = Volley.newRequestQueue(this, new OkHttpStack(okHttpClient));
Import your libraries and yet we will see an error with OkHttpStack(okHttpClient) so you only need to copy this code provided by @bryanstern Class OkHttpStack so create the file import and enjoy it
answered Aug 18 '16 at 13:39


Ezequiel GarcíaEzequiel García
1,384710
1,384710
Hello, I'm curious how you handle SSL with OkHTTPStack? I'm currrently using HurlStack with SSL in Volley and would like to switch to OkHTTP so I can use Stetho for network tracing.
– Woppi
Dec 20 '16 at 9:19
thank you , thanks a lot!
– Ninad Kambli
Jan 4 '17 at 7:29
add a comment |
Hello, I'm curious how you handle SSL with OkHTTPStack? I'm currrently using HurlStack with SSL in Volley and would like to switch to OkHTTP so I can use Stetho for network tracing.
– Woppi
Dec 20 '16 at 9:19
thank you , thanks a lot!
– Ninad Kambli
Jan 4 '17 at 7:29
Hello, I'm curious how you handle SSL with OkHTTPStack? I'm currrently using HurlStack with SSL in Volley and would like to switch to OkHTTP so I can use Stetho for network tracing.
– Woppi
Dec 20 '16 at 9:19
Hello, I'm curious how you handle SSL with OkHTTPStack? I'm currrently using HurlStack with SSL in Volley and would like to switch to OkHTTP so I can use Stetho for network tracing.
– Woppi
Dec 20 '16 at 9:19
thank you , thanks a lot!
– Ninad Kambli
Jan 4 '17 at 7:29
thank you , thanks a lot!
– Ninad Kambli
Jan 4 '17 at 7:29
add a comment |
If you want to use Stetho for volley without using OkHttp stack.
Please refer this link. Stetho for Volley
add a comment |
If you want to use Stetho for volley without using OkHttp stack.
Please refer this link. Stetho for Volley
add a comment |
If you want to use Stetho for volley without using OkHttp stack.
Please refer this link. Stetho for Volley
If you want to use Stetho for volley without using OkHttp stack.
Please refer this link. Stetho for Volley
answered Nov 20 '18 at 7:06
Darshan KapasiDarshan Kapasi
5210
5210
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f32012160%2fhow-to-use-stetho-with-volley%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown