如何将服务器端的图片显示在安卓客户端?

大家好,请问如何将服务器端的图片显示在安卓客户端呢?
打算实现选择相册图片显示确认后上传到服务器,最后客户端显示服务器中图片,有点没什么思路,请大家帮帮忙,先谢过了。
主要是客户端里显示上传在服务器中的图片。

该回答内容部分引用GPT,GPT_Pro更好的解决问题
要想将服务器端的图片显示在安卓客户端,可以采用以下步骤:

  1. 在服务器端,使用HttpURLConnection类与安卓客户端连接,并设置相关参数:
    URL url = new URL(urlStr);
    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    connection.setRequestMethod("GET");
    connection.setConnectTimeout(5000);
    
  2. 获取服务器端的图片流,将其存储在Bitmap对象中:
    InputStream is = connection.getInputStream();
    Bitmap bitmap = BitmapFactory.decodeStream(is);
    
  3. 将图片对象显示在安卓客户端:
    ImageView imageView = findViewById(R.id.image_view);
    imageView.setImageBitmap(bitmap);
    
  4. 关闭HttpURLConnection连接:
    if(connection != null){
     connection.disconnect();
    }
    
    以上就是将服务器端的图片显示在安卓客户端的步骤,相信大家都能够搞定。
    如果回答有帮助,望采纳。

虽然没太理解作者的意思 但是加载网络图片可以用glide加载图片库https://github.com/bumptech/glide

你要问的是安卓如何显示网络图片还是后端如何提供在线图片?

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^