Skip to content

Instantly share code, notes, and snippets.

@amitkma
Created May 25, 2017 14:46
Show Gist options
  • Save amitkma/fe0c59ef00b9ee18aa8fab8ae43c17be to your computer and use it in GitHub Desktop.
Save amitkma/fe0c59ef00b9ee18aa8fab8ae43c17be to your computer and use it in GitHub Desktop.
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