@Override public void onDataReceived(Data data) { if (data.type != Protocol.byteType() || (data.bData != Protocol.Req.off() && data.bData != Protocol.Req.on())) return; CustomService service = null; if (data.cmd == Protocol.Cmd.sensOrient()) { service = orientationService; } else if (data.cmd == Protocol.Cmd.sensLocation()) { service = locationService; } else if (data.cmd == Protocol.Cmd.sensLight()) { service = lightService; } else if (data.cmd == Protocol.Cmd.camState()) { service = videoService; } if (service == null) return; Message mes = new Message(); mes.obj = service; mes.arg1 = data.bData; customServiceHandler.sendMessage(mes); }