格式错误的URL异常:无协议

时间:2019-10-03 06:57:37

标签: android kotlin bitmap

http://13.232.62.239/muallim/public/profilePicture/phpyOk6UN

我正在尝试将此URL转换为位图图像,它给我一个MalformedUrlException错误。

这是我的以下代码:

    fun getBitmapFromURL(src: String): BitmapDrawable? {
    val connection = URL(src).openConnection()
    connection.connect();
    val input = connection.getInputStream()

    val x = BitmapFactory.decodeStream(input);
    return BitmapDrawable(Resources.getSystem(), x)
}

其中src:字符串是我要发送到此方法的URL,以将该图像链接转换为位图。

PS:如果单击上面的URL并添加点(。),则链接将显示图像。 所以我的问题是:是因为圆点(末尾的特殊字符给出了异常还是其他原因) 谁能帮我这个忙。 ?

谢谢

0 个答案:

没有答案