TwinPrime是一个SDK,可以通过几行代码(www.twinprime.com)以100%的方式增强您应用的互联网连接。
显然,我需要做的就是将以下代码放在我的MainActivity中:
URLConnection httpConn = TPURLConnection.openConnection("your-URL");
然后在有HttpConnection的地方附上以下内容:
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;
}
}
我的问题是我不知道在哪里附上它。我已经联系了他们的客户支持,但也许SO上的某人有过与他们合作的经历?
IQueryable<User> regUsers = db.Users;
答案 0 :(得分:0)
这就是我完成它的方式。
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;
}
}