Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Mia methodos en touti
- public static Bitmap getBitmapFromURL(String src) {
- try {
- URL url = new URL(src);
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.setDoInput(true);
- connection.connect();
- InputStream input = connection.getInputStream();
- Bitmap myBitmap = BitmapFactory.decodeStream(input);
- return myBitmap;
- } catch (IOException e) {
- e.printStackTrace();
- return null;
- }
- }
- //I alli en touti
- private byte[] Blogthemage(String url){
- try {
- URL imageUrl = new URL(url);
- URLConnection urlConnection = imageUrl.openConnection();
- ByteArrayOutputStream buffer = new ByteArrayOutputStream();
- InputStream is = urlConnection.getInputStream();
- BufferedInputStream bis = new BufferedInputStream(is);
- byte[] data = new byte[500];
- int current = 0;
- while ((current = bis.read(data,0,data.length)) != -1) {
- buffer.write(data,0,current);
- }
- return data;
- } catch (Exception e) {
- Log.d("ImageManager", "Error: " + e.toString());
- }
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement