Call AsyncTask methods from another class/service (callbacks?)

Posted by TiGer on Stack Overflow See other posts from Stack Overflow or by TiGer
Published on 2010-06-01T07:30:20Z Indexed on 2010/06/01 7:33 UTC
Read the original article Hit count: 160

Filed under:
|
|

Hi,

I was wondering if it's possible to call specific methods defined within the AsynTask class from another class and/or service ? In my specific case I have a Service playing some sounds, but the sound is selected from a List with available sounds...

When a sounds is selected it is downloaded from my home server, this takes some time (not much, let's say around the 3-4 seconds, the sounds/effects aren't big in size)... So my problem at the moment is that I have a service to play those sounds, and when I select one I wanted to show a progressdialog... The way (if I understood correctly) is to use an AsyncTask, but the only thing the AsyncTask will do is telling my Service to play a specific sound from my server... So there is no "callback" from the service to the Asynctask...

How can I achieve that ? How can I call a running AsyncTask, which sits in another class, and tell him all work is done and thus he can stop showing the ProgressDialog ? Or am I over-engineering it and there are other ways ? Thanks in advance...

© Stack Overflow or respective owner

Related posts about android

Related posts about callback