0
库存,因为后端开发人员在FTP服务器中存储图像,我需要在ImageView中显示这些图像而不保存到SD卡。Android - FTP在ImageView中显示图像,但不存储图像中的图像
是否有可能检索图像(jpg/png)并将其转换为位图并直接将其显示到ImageView而无需保存。
我在寻找很多,但所有使用的工艺都保存到SD卡的方式。
库存,因为后端开发人员在FTP服务器中存储图像,我需要在ImageView中显示这些图像而不保存到SD卡。Android - FTP在ImageView中显示图像,但不存储图像中的图像
是否有可能检索图像(jpg/png)并将其转换为位图并直接将其显示到ImageView而无需保存。
我在寻找很多,但所有使用的工艺都保存到SD卡的方式。
public class async extends AsyncTask<String, Integer, Bitmap> {
@Override
protected Bitmap doInBackground(String... strings) {
public static Bitmap getBitmapFromURL(String src) {
try {
URL url = new URL(src);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();
Bitmap myBitmap = BitmapFactory.decodeStream(input);
return myBitmap;
} catch (IOException e) {
// Log exception
return null;
}
}
}
@Override
protected void onPostExecute(Bitmap result) {
if(result != null)
imageView.setImageBitmap(result)
}
}
如果你有直接的URL的文件,然后你可以从URI –
图像加载到ImageView的是,我有直接的URL的形象,请我需要更多的帮助,在打击代码没有工作与我..图像仍然没有出现。 – Safa
添加断点并记录变量的值。下面的代码应该可以工作,它为我工作。 **除非你有FTP所需的一些认证** –