我尝试从需要登录才能查看特定图片的网址加载图片时遇到了Android工作室的问题。如何从需要登录的网址获取图片?
这是获取图像URL的代码,它返回该图像的绝对URL。
Document document = Jsoup.connect(url + "home").timeout(0).header("Cookie", cookie).get();
String imageUrl = document.select("MY CSS SELECTOR").attr("abs:data-src");
,我使用此代码到该URL转换为位图图像
URLConnection connection = new java.net.URL(imageUrl).openConnection();
connection.setRequestProperty("Cookie", cookie);
connection.connect();
Bitmap temp = BitmapFactory.decodeStream(connection.getInputStream());
所以我猜测,如预期我的第二个代码不工作,我想知道我可以当我在我登录负载图像只显示。
感谢
尝试此链接: https://stackoverflow.com/a/45073477/4116560 – sam