当前位置:编程学习 > wap >>

Activity和Service通过广播通讯时的线程同步问题

--------------------编程问答-------------------- 沙发自己抢,肥水不留外人田!

有人回复了我的帖子,竟然没发现。用《Csdn收音机》告别烦恼! --------------------编程问答-------------------- 1.检查service是否成功在后台运行
2.接受广播的activity的在manifest中<intent-filter>的设置是否正确
--------------------编程问答-------------------- service运行、广播消息、activity接受消息这些都没问题,上述问题是加了同步以后才出现的。 --------------------编程问答-------------------- 又尝试了对整个onReceive方法了个同步,会报receiver对象不能锁定:

public class MyReceiver extends BroadcastReceiver {
@Override
synchronized public void onReceive(Context context,final Intent intent) {
String action = intent.getAction();


错误信息是:

java.lang.IllegalMonitorStateException,Receiver not locked by thread before wait()
补充:移动开发 ,  Android
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,