android - HandlerThread and Handler: how to use AudioRecord.setRecordPositionUpdateListener? -
i'm confused handler
, handlerthread
classes usage. reason i'm trying use them want utilize audiorecord
class , setrecordpositionupdatelistener
method (reference). methos description says:
use method receive audiorecord events in handler associated thread 1 in created audiotrack instance.
and that's want - setup audiorecord
in main thread, receive data in working thread. figure need handlerthread
i've created , started one. i've defined callback method implements audiorecord.onrecordpositionupdatelistener
interface. want callback called worker handlerthread
. don't understand how create handler
pass setrecordpositionupdatelistener
.
to associate handler
thread, should create passing corresponding looper
in constructor. so, if have handlerthread
can done in following way:
looper looper = myhandlerthread.getlooper(); handler handler = new handler(looper);
and that's it, use handler in setrecordpositionupdatelistener
method , callback executed @ worker thread. if need more explanation on handler
, looper
, handlerthread
, can take here.
Comments
Post a Comment