Skip to content

bug #2

Description

@xieguangwei

private final Handler mHandler = new Handler(Looper.getMainLooper()) {
@OverRide
public void handleMessage(Message msg) {
switch (msg.what) {
case APPLE_INFO:
Apple apple = (Apple) msg.obj;
//观察者模式,通知所有客户端
final int clientNum = mCallbacks.beginBroadcast();
for (int i = 0; i < clientNum; i++) {
IRemoteServiceCallBack callBack = mCallbacks.getBroadcastItem(i);
if (callBack != null && apple != null) {
try {
callBack.noticeAppleInfo(apple);
} catch (RemoteException e) {
e.printStackTrace();
}
}
mCallbacks.finishBroadcast();
}
break;
}
super.handleMessage(msg);
}
mCallbacks.finishBroadcast();应该放到for循环后面,不然通知一个就结束了

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions