Java 将TwinPrime添加到我的HttpURLConnection
TwinPrime是一个SDK,它可以通过几行代码(www.TwinPrime.com)将应用程序的互联网连接能力提高100% 显然,我所需要做的就是在我的MainActivity中放置以下代码:Java 将TwinPrime添加到我的HttpURLConnection,java,android,httpurlconnection,androidhttpclient,Java,Android,Httpurlconnection,Androidhttpclient,TwinPrime是一个SDK,它可以通过几行代码(www.TwinPrime.com)将应用程序的互联网连接能力提高100% 显然,我所需要做的就是在我的MainActivity中放置以下代码: new TwinPrimeSDK(getApplicationContext(), "API_KEY"); try { URLConnection httpConn = TPURLConnection.openConnection("your-URL"); } catch (IOExcepti
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;
}
}
将你的应用程序的互联网连接能力提高100%
这意味着什么?如果我知道的话,见鬼!听起来很有趣。老实说,我会检查你是否需要这样的服务,并检查他们的隐私政策,看起来他们通过分析你的连接数据来提供这些服务。