0

I'm trying to run a Looper within a separate thread. Essentially the purpose of initating a looper on this thread, is so that it will run the appropriate SoundPool.OnLoadCompleteListener instances.

So code wise:

Looper.prepare();
Looper.loop();

However the call to loop does not return due to being an infinite loop. How then am I suppose to call Looper.myLooper.quit()?

Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
  • 1
    from the other thread? ... – Selvin Sep 22 '14 at 11:55
  • How could I do that? Would it be just a simple case of passing it Looper.myLooper(), and then calling quit() on that Looper instance? – Chris Stryczynski Sep 22 '14 at 11:57
  • i'm pretty sure that you are doing something wrong ... the main purpose of looper is to consume the messages from the other thread ... it is just inf loop it chceck own message queue and consume if there is a message ... the messages can be post from other threads but they are executed on looper thread ... could you provide more context on what you wana achive? – Selvin Sep 22 '14 at 12:01
  • you dont need any other thread nor Looper on that thread, just let SoundPool.OnLoadCompleteListener to be called on the main UI thread – pskink Sep 22 '14 at 12:15
  • Correct, I'm not issuing any additional messages / handler. The only reason I'm using looper in this thread is because I want to run the OnLoadCompleteListener(s) which seem to execute only in a looper. I don't want it to run on the main thread as I'm using a semaphore to lock it until all the OnLoadCompleteListener(s) have completed. As described here: http://stackoverflow.com/a/14782648/1663462 – Chris Stryczynski Sep 22 '14 at 12:23

0 Answers0