Created
May 25, 2017 14:46
-
-
Save amitkma/fe0c59ef00b9ee18aa8fab8ae43c17be 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
class ExampleClass { | |
public ExampleClass() { | |
} | |
@CallOnAnyThread | |
public Bitmap getBitmapFromURL(String src) { | |
try { | |
URL url = new URL(src); | |
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); | |
connection.setDoInput(true); | |
connection.connect(); | |
InputStream input = connection.getInputStream(); | |
return BitmapFactory.decodeStream(input); | |
} catch (IOException e) { | |
// Log exception | |
return null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment