在做一个蓝牙的程序,service启动之后,向连接的蓝牙设备发送消息,等收到返回的消息之后再执行主线程,应该怎么做啊。
ringa_lee2017-04-17 14:28:06
Is this a good experience? Why let the main thread wait? Usually time-consuming operations should not be done in the main thread. You all know 等收到返回的消息之后再执行主线程
, why is it not easy to do it?
1. Observer mode, listener.onReceive(Msg msg).
2. Android has its own broadcast. When Bluetooth receives a message, it is OK to send a broadcast. The main thread receives the broadcast and processes it.
PHP中文网2017-04-17 14:28:06
"After receiving the returned message" there should be a "notification" (callback method) to do the operation you want ~
怪我咯2017-04-17 14:28:06
I am also currently working on a Bluetooth and smart bracelet app. Do you have an API for Bluetooth BLE operation?