4

So I recently learned about Stetho and would like to implement it to intercept network requests. However, I cannot find an example on how to do it 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) {
        // this will make sure that this particular instance will last the lifetime of the app
        // getApplicationContext() is key, it keeps you from leaking the Activity or BroadcastReceiver if someone passes one in.
        mRequestQueue = Volley.newRequestQueue(mCtx.getApplicationContext(), hurlStack);
    }
    return mRequestQueue;
}

According to the docu: If you are using HttpURLConnection, you can use StethoURLConnectionManager

But I cannot figure out how to do it after checking the class. Maybe someone has experience on this issue? Thanks a lot.

Source: https://github.com/facebook/stetho/blob/master/stetho-urlconnection/src/main/java/com/facebook/stetho/urlconnection/StethoURLConnectionManager.java

Source: http://facebook.github.io/stetho/#integrations

Woppi
  • 5,303
  • 11
  • 57
  • 81
  • I have a same problem. – M.Rezaei Jan 03 '17 at 06:37
  • 1
    @M.Rezaei I have not solved this yet (skipped this issue :p ). There's a reply from the community https://github.com/facebook/stetho/issues/461, if that might help you. – Woppi Jan 03 '17 at 06:39
  • @Woppi please check it. That may help you http://stackoverflow.com/questions/32012160/how-to-use-stetho-with-volley/32210781#32210781 – Sabeeh Jan 31 '17 at 17:16

0 Answers0