android - The specified message queue synchronization barrier token has not been posted -
i have app binded service. sending messages service, getting following error:
e/androidruntime(28216): java.lang.illegalstateexception: specified message queue synchronization barrier token has not been posted or has been removed.
sometimes error instead:
android.util.androidruntimeexception: { what=888 when=0 } message in use.
sometimes ui freezes. communicating service activity , visa versa through handlers.
public void init(ibinder service){ playerservice = new messenger(service); setbound(true); try { message msg = message.obtain(null, playerservice.msg_register_client); msg.replyto = messenger; playerservice.send(msg); while(!messagequeue.isempty()){ playerservice.send(messagequeue.remove()); } } catch (remoteexception e) { // in case service has crashed before log.d(player.tag, "problem binding player messenger " + e.getmessage()); } }
here method consistenly results on freezes, second time called.
public void play(string url) { message msg = message.obtain(null, playerservice.play, 0, 0); msg.setdata(geturlbundle(url)); sendmessage(msg); } private void sendmessage(message message){ if(!isbound){ log.d(player.tag, "isnt bound, queueing message"); messagequeue.add(message); }else { try { playerservice.send(message); } catch (remoteexception e) { e.printstacktrace(); } } }
i'm new threading, messengers , handlers, appreciated, :)
problem queue messages, allocated message.obtain()
. need create copy of message calling
message m = new message(); m.copyfrom(message);
and add copied message m
queue.
Comments
Post a Comment