So, I recently learned about Stetho and would like to implement it to intercept network requests. However, I cannot find an example of how to do this for URLConnection:
Here is a snippet of my VolleySingleton class.
private RequestQueue getRequestQueue() {
HurlStack hurlStack = new HurlStack() {
@Override
protected HttpURLConnection createConnection(URL url) throws IOException {
HttpsURLConnection httpsURLConnection = (HttpsURLConnection) super.createConnection(url);
try {
httpsURLConnection.setSSLSocketFactory(getSSLSocketFactory());
httpsURLConnection.setHostnameVerifier(getHostnameVerifier());
} catch (Exception e) {
e.printStackTrace();
}
return httpsURLConnection;
}
};
if(mRequestQueue == null) {
mRequestQueue = Volley.newRequestQueue(mCtx.getApplicationContext(), hurlStack);
}
return mRequestQueue;
}
According to the doc:
If you use HttpURLConnection, you can use StethoURLConnectionManager
But I can’t figure out how to do this after checking the class. Maybe someone has experience on this issue? Many thanks.
Source: https://github.com/facebook/stetho/blob/master/stetho-urlconnection/src/main/java/com/facebook/stetho/urlconnection/StethoURLConnectionManager.java
Source: http://facebook.imtqy.com/stetho/#integrations