Skip to content

Instantly share code, notes, and snippets.

@kelmer44
Last active May 13, 2020 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kelmer44/b092747d8b11ffd07801d6e2f8b733ff to your computer and use it in GitHub Desktop.
Save kelmer44/b092747d8b11ffd07801d6e2f8b733ff to your computer and use it in GitHub Desktop.
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