大家好,请问如何将服务器端的图片显示在安卓客户端呢?
打算实现选择相册图片显示确认后上传到服务器,最后客户端显示服务器中图片,有点没什么思路,请大家帮帮忙,先谢过了。
主要是客户端里显示上传在服务器中的图片。
该回答内容部分引用GPT,GPT_Pro更好的解决问题
要想将服务器端的图片显示在安卓客户端,可以采用以下步骤:
URL url = new URL(urlStr);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setConnectTimeout(5000);
InputStream is = connection.getInputStream();
Bitmap bitmap = BitmapFactory.decodeStream(is);
ImageView imageView = findViewById(R.id.image_view);
imageView.setImageBitmap(bitmap);
if(connection != null){
connection.disconnect();
}
以上就是将服务器端的图片显示在安卓客户端的步骤,相信大家都能够搞定。虽然没太理解作者的意思 但是加载网络图片可以用glide加载图片库https://github.com/bumptech/glide
你要问的是安卓如何显示网络图片还是后端如何提供在线图片?
不知道你这个问题是否已经解决, 如果还没有解决的话: