Custom changeable handler when a Service finishes downloading a file

Posted by jax on Stack Overflow See other posts from Stack Overflow or by jax
Published on 2010-05-30T16:59:07Z Indexed on 2010/05/30 17:02 UTC
Read the original article Hit count: 211

Filed under:

I have a Service that downloads a file from the internet. What I want is for the response (an InputStream in this case) to be handled by a custom handler that can be switched (like a strategy pattern) but I can't figure out how to do this.

So basically the User of the API would be able to plug in different handlers for the response, some would parse XML, others might save files etc.

I realise I could pass through the activity context and execute the method from this (given some interface) but I don't want to do this obviously, in case the Activity is closed in the meantime while the file is still downloaded.

How might I do this?

© Stack Overflow or respective owner

Related posts about android