将 TwinPrime 添加到我的 HttpURLConnection

Adding TwinPrime to my HttpURLConnection

TwinPrime 是一个 SDK,据说可以通过几行代码 (www.twinprime.com) 将您的应用程序的互联网连接性提高 100%。

显然我需要做的就是将以下代码放入我的 MainActivity 中:

new TwinPrimeSDK(getApplicationContext(), "API_KEY");
try {
    URLConnection httpConn = TPURLConnection.openConnection("your-URL");
} catch (IOException e) {
    e.printStackTrace();
}

然后在有 HttpConnection 的地方附加以下内容:

URLConnection httpConn = TPURLConnection.openConnection("your-URL");

我的问题是我不知道将它附加到哪里。我已经联系了他们的客户支持,但也许 SO 上的某个人对他们有过经验?

private Bitmap getBitmap(String url) {
        File f = fileCache.getFile(url);

        Bitmap b = decodeFile(f);
        if (b != null) {
            return b;
        }

        // Download Images from the Internet
        try {
            Bitmap bitmap = null;
            URL imageUrl = new URL(url);
            HttpURLConnection conn = (HttpURLConnection) imageUrl.openConnection();
            conn.setConnectTimeout(30000);
            conn.setReadTimeout(30000);
            conn.setInstanceFollowRedirects(true);
            InputStream is = conn.getInputStream();
            OutputStream os = new FileOutputStream(f);
            FeedUtils.CopyStream(is, os);
            os.close();
            conn.disconnect();
            bitmap = decodeFile(f);
            return bitmap;
        } catch (Throwable ex) {
            ex.printStackTrace();
            if (ex instanceof OutOfMemoryError)
                memoryCache.clear();
            return null;
        }
    }

我就是这样完成的。

private Bitmap getBitmap(String url) {
        File f = fileCache.getFile(url);

        Bitmap b = decodeFile(f);
        if (b != null) {
            return b;
        }

        // Download Images from the Internet
        try {
            Bitmap bitmap = null;
            URL imageUrl = new URL(url);
            HttpURLConnection httpConn = (HttpURLConnection) TPURLConnection.openConnection(url);
//            HttpURLConnection conn = (HttpURLConnection) imageUrl.openConnection();
            httpConn.setConnectTimeout(30000);
            httpConn.setReadTimeout(30000);
            httpConn.setInstanceFollowRedirects(true);
            InputStream is = httpConn.getInputStream();
            OutputStream os = new FileOutputStream(f);
            FeedUtils.CopyStream(is, os);
            os.close();
            httpConn.disconnect();
            bitmap = decodeFile(f);
            return bitmap;
        } catch (Throwable ex) {
            ex.printStackTrace();
            if (ex instanceof OutOfMemoryError)
                memoryCache.clear();
            return null;
        }
    }