[英]System.err when fetching an image in Android
我正在使用Messenger服務從URL異步獲取圖像,但是LogCat拋出了奇怪的錯誤消息:
W / System.err(26180):從./org/apache/harmony/awt/www/content/image/png.class讀取時出錯
- 要么 -
W / System.err(26180):從./org/apache/harmony/awt/www/content/image/jpeg.class讀取時出錯
有趣的是,一切正常。 第一次嘗試成功將圖像解碼為位圖。
這是我的代碼:
@Override
public void onHandleIntent(Intent i) {
int position = (Integer)i.getExtras().get(EXTRA_POSITION);
String imageUrl = (String)i.getExtras().get(EXTRA_URL);
Messenger messenger = (Messenger)i.getExtras().get(EXTRA_MESSENGER);
Message msg = Message.obtain();
Bitmap bitmap = null;
try {
bitmap = BitmapFactory.decodeStream((InputStream)new URL(imageUrl).getContent());
msg.arg1 = Activity.RESULT_OK;
msg.arg2 = position;
msg.obj = bitmap;
} catch(Exception e) {
Log.e("RSSForHC", "Exception getting image", e);
msg.arg1 = Activity.RESULT_CANCELED;
msg.obj = e;
}
try {
messenger.send(msg);
} catch (Exception e) {
Log.w("RSSForHC","Exception sending results to activity", e);
}
}
該錯誤明確地拋出在此行上:
bitmap = BitmapFactory.decodeStream((InputStream)new URL(imageUrl).getContent());
由於一切正常,我的問題是忽略此錯誤是否可以接受? 有誰知道為什么會引發此錯誤,以及如何糾正或處理該錯誤?
這使我擺脫了這些信息。 當然,邁克爾可能還是對的,忽略它們是可以的。
我替換了Drawable.createFromStream((((InputStream)new URL(urlString).getContent()),“ name”); 同
Drawable.createFromStream((new URL(url))。openConnection()。getInputStream(),“名稱”);
當然,這不完全是您的代碼,但是我懷疑用openConnection()。getInputStream()替換getContent()也對您有用。
顯然,這是Apache / Harmony框架中的錯誤。 我想您可能會忽略它,即使您想要也無法在其中更改代碼:)對於apache / harmony開發人員來說,這有點像日志記錄的東西,您不必在意。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.