Last active
May 13, 2020 14:40
-
-
Save kelmer44/b092747d8b11ffd07801d6e2f8b733ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun getBitmap(url: String, height: Int): Bitmap? { | |
return try { | |
val imageUrl = URL(url) | |
val connection = imageUrl.openConnection() as HttpURLConnection | |
connection.instanceFollowRedirects = true | |
val inputStream = connection.inputStream | |
val outputStream = FileOutputStream(f) | |
copyStream(inputStream, outputStream) | |
outputStream.close() | |
decodeFile(f, height) | |
} catch (e: Exception) { | |
null | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment