我正在尝试从这个给定的短 url/redirect 从 facebook 下载图像,但在我的情况下它不起作用 - 这是我的代码:
private Bitmap getBitmap(String url) {
try {
InputStream is = (InputStream) new URL(url).getContent();
Bitmap btm = BitmapFactory.decodeStream(is);
is.close();
return btm;
}catch (MalformedURLException e) {
Log.v(Constants.LOG_TAG, "[Error] " + e + ": " + e.getMessage());
e.printStackTrace();
return null;
}catch (IOException e) {
Log.v(Constants.LOG_TAG, "[Error] " + e + ": " + e.getMessage());
e.printStackTrace();
return null;
}
}
如果我使用长链接,它也可以正常工作,但我需要从短链接中获取这张照片。有谁知道如何解决这个问题?谢谢你。