Has anyone had much use with the executor service in android?
I have a class that Implements runnable that gets an image from a url and decodes it into a bitmap, like so:
Using java Syntax Highlighting
- IconRunnable implements Runnable{
- String urlString = "";
- Bitmap bitmap = null;
- public void run() {
- InputStream is = null;
- BufferedInputStream bis = null;
- try {
- URL url = new URL(urlString);
- URLConnection connection = url.openConnection();
- connection.connect();
- is = conn.getInputStream();
- bis = new BufferedInputStream(is);
- bmp = BitmapFactory.decodeStream(bis);
- } catch (IOException e) {
- } finally {
- try {
- is.close();
- bis.close();
- } catch (IOException e) {
- }
- }
- }
Parsed in 0.032 seconds, using GeSHi 1.0.8.4
My other class IconLoader runs the Executor Service and executes this runnable task inside a method of its own, like so:
Using java Syntax Highlighting
- public class IconLoader {
- ExecutorService executor = Executors.newFixedThreadPool(3);
- IconRunnable icon = new IconRunnable();
- public void execute(){
- executor.execute(icon);
- }
- }
Parsed in 0.030 seconds, using GeSHi 1.0.8.4
Can anyone tell me how I can get the stored bitmap from the runnable class back to the main so I can attach it?
Thanks


