This method will do the trick with kotlin coroutine so it won't block the UI Main thread & will return resized circle bitmap image(like profile image)
private var image: Bitmap? = null
private fun getBitmapFromURL(src: String?) {
CoroutineScope(Job() + Dispatchers.IO).launch {
try {
val url = URL(src)
val bitMap = BitmapFactory.decodeStream(url.openConnection().getInputStream())
image = Bitmap.createScaledBitmap(bitMap, 100, 100, true)
} catch (e: IOException) {
// Log exception
}
}
}