BitmapFactory无法解码流:Android中的java.io.FileNotFoundException
我试图在线从我的数据库中获取图片,在我的“imagelink”表中的数据字段中,我将上传图片的url放在那里,但不幸的是,它给了我这个错误BitmapFactory无法解码流:Android中的java.io.FileNotFoundException,java,android,database,image,Java,Android,Database,Image,我试图在线从我的数据库中获取图片,在我的“imagelink”表中的数据字段中,我将上传图片的url放在那里,但不幸的是,它给了我这个错误 02-08 15:05:29.432 14364-14364/com.example.jithea.testlogin E/BitmapFactory﹕ Unable to decode stream: java.io.FileNotFoundException: /http:/agustiniancampusevents.site40.net/newsD
02-08 15:05:29.432 14364-14364/com.example.jithea.testlogin E/BitmapFactory﹕ Unable to decode stream: java.io.FileNotFoundException: /http:/agustiniancampusevents.site40.net/newsDB/images/Visual%20Report%20Filipino%20Final-12%20copy.JPG: open failed: ENOENT (No such file or directory)
以下是我在onPostExecute中的代码:
protected void onPostExecute(String file_url) {
// dismiss the dialog after getting all products
pDialog.dismiss();
// updating UI from Background Thread
runOnUiThread(new Runnable() {
public void run() {
/**
* Updating parsed JSON data into ListView
* */
ListAdapter adapter = new SimpleAdapter(
NewsActivity.this, productsList,
R.layout.news_list_item, new String[]{TAG_PID, TAG_IMAGELINK,
TAG_NEWSTITLE, TAG_DESCRIPTION},
new int[]{R.id.pid, R.id.imageView, R.id.newstitle, R.id.description});
// updating listview
setListAdapter(adapter);
}
});
}
使用
BitmapFactory.decodeStream
而不是BitmapFactory.decodeFile
try ( InputStream is = new URL( file_url ).openStream() ) {
Bitmap bitmap = BitmapFactory.decodeStream( is );
}
请出示一些代码!!这是因为文件“/http:/agustiniancapsusevents.site40.net/newsDB/images/Visual%20Report%20Filipino%20Final-12%20copy.JPG”不存在。是否将URL传递给从文件读取的方法?(url不是文件。)如何将url传递给读取文件的方法?“使用资源进行尝试需要API级别19”